1 #![feature(unboxed_closures)]
3 // Tests that we can't move out of an unboxed closure environment
4 // if the upvar is captured by ref or the closure takes self by
7 fn to_fn<A,F:Fn<A>>(f: F) -> F { f }
8 fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f }
9 fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f }
15 let f = to_fn(|| drop(x)); //~ ERROR cannot move
19 let f = to_fn_mut(|| drop(x)); //~ ERROR cannot move
23 let f = to_fn_once(|| drop(x)); // OK -- FnOnce
28 let f = to_fn(move || drop(x)); //~ ERROR cannot move
32 let f = to_fn_mut(move || drop(x)); //~ ERROR cannot move
36 let f = to_fn_once(move || drop(x)); // this one is ok