2022-12-25 16:51:11 -08:00
|
|
|
//@ run-rustfix
|
|
|
|
// Test that a by-ref `FnMut` closure gets an error when it tries to
|
|
|
|
// consume a value.
|
|
|
|
|
|
|
|
fn call<F>(f: F) where F : Fn() {
|
|
|
|
f();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let y = vec![format!("World")];
|
|
|
|
call(|| {
|
2024-03-13 03:41:41 +00:00
|
|
|
<Vec<String> as Clone>::clone(&y.clone()).into_iter();
|
2022-12-25 16:51:11 -08:00
|
|
|
//~^ ERROR cannot move out of `y`, a captured variable in an `Fn` closure
|
|
|
|
});
|
|
|
|
}
|