rust/src/test/ui/fn/fn-closure-mutable-capture.rs

11 lines
269 B
Rust
Raw Normal View History

pub fn bar<F: Fn()>(_f: F) {}
pub fn foo() {
let mut x = 0;
bar(move || x = 1);
//~^ ERROR cannot assign to captured outer variable in an `Fn` closure
//~| NOTE `Fn` closures cannot capture their enclosing environment for modifications
}
fn main() {}