1 // ignore-tidy-linelength
3 //[mir]compile-flags: -Z borrowck=mir
5 #![feature(unboxed_closures)]
9 fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f }
13 to_fn_once(move|| { x = 2; });
14 //[ast]~^ ERROR: cannot assign to immutable captured outer variable
15 //[mir]~^^ ERROR: cannot assign to `x`, as it is not declared as mutable
17 let s = std::io::stdin();
18 to_fn_once(move|| { s.read_to_end(&mut Vec::new()); });
19 //[ast]~^ ERROR: cannot borrow immutable captured outer variable
20 //[mir]~^^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable