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 
set(x: &mut usize)5 fn set(x: &mut usize) { *x = 0; }
6 
main()7 fn main() {
8     let x = 0;
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
14     || set(&mut x); //~ ERROR cannot borrow
15     || x = 1; //~ ERROR cannot assign
16     || set(&mut x); //~ ERROR cannot borrow
17 }
18