summaryrefslogtreecommitdiffstats
path: root/src/test/ui/borrowck/borrow-immutable-upvar-mutation-impl-trait.rs
blob: 57198cb95e770113955d02388534867706d85f93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#![feature(unboxed_closures)]

// Tests that we can't assign to or mutably borrow upvars from `Fn`
// closures (issue #17780)

fn main() {}

fn bar() -> impl Fn() -> usize {
    let mut x = 0;
    move || {
        x += 1; //~ ERROR cannot assign
        x
    }
}