rust/tests/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.fixed

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
336 B
Rust
Raw Normal View History

2022-12-25 18:51:11 -06: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(|| {
y.clone().into_iter();
//~^ ERROR cannot move out of `y`, a captured variable in an `Fn` closure
});
}