rust/tests/ui/closures/closure-immutable-outer-variable.rs
2024-02-16 20:02:50 +00:00

14 lines
261 B
Rust

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