]> git.proxmox.com Git - rustc.git/blame - src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / unboxed-closures / unboxed-closure-immutable-capture.rs
CommitLineData
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
5fn set(x: &mut usize) { *x = 0; }
6
7fn 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}