]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Test that even unboxed closures that are capable of mutating their |
2 | // environment cannot mutate captured variables that have not been | |
3 | // declared mutable (#18335) | |
4 | ||
5 | fn set(x: &mut usize) { *x = 0; } | |
6 | ||
7 | fn main() { | |
c34b1796 | 8 | let x = 0; |
85aaf69f SL |
9 | move || x = 1; //~ ERROR cannot assign |
10 | move || set(&mut x); //~ ERROR cannot borrow | |
11 | move || x = 1; //~ ERROR cannot assign | |
12 | move || set(&mut x); //~ ERROR cannot borrow | |
13 | || x = 1; //~ ERROR cannot assign | |
48663c56 | 14 | || set(&mut x); //~ ERROR cannot borrow |
85aaf69f | 15 | || x = 1; //~ ERROR cannot assign |
48663c56 | 16 | || set(&mut x); //~ ERROR cannot borrow |
1a4d82fc | 17 | } |