2 // Test that we mutate a counter on the stack only when we expect to.
4 fn call<F>(f: F) where F : FnOnce() {
9 let y = vec![format!("Hello"), format!("World")];
10 let mut counter = 22_u32;
13 // Move `y`, but do not move `counter`, even though it is read
14 // by value (note that it is also mutated).
15 for item in y { //~ WARN unused variable: `item`
20 assert_eq!(counter, 88);
23 // this mutates a moved copy, and hence doesn't affect original
24 counter += 1; //~ WARN value assigned to `counter` is never read
25 //~| WARN unused variable: `counter`
27 assert_eq!(counter, 88);