rust/src/test/ui/closures/closure-immutable-outer-variable.fixed
2020-05-29 17:46:38 +02:00

14 lines
264 B
Rust

// run-rustfix
// Point at the captured immutable outer variable
fn foo(mut f: Box<dyn FnMut()>) {
f();
}
fn main() {
let mut y = true;
foo(Box::new(move || y = !y) as Box<_>);
//~^ ERROR cannot assign to `y`, as it is not declared as mutable
}