]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/do-not-suggest-adding-move-when-closure-is-already-marked-as-move.stderr
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / do-not-suggest-adding-move-when-closure-is-already-marked-as-move.stderr
1 error: captured variable cannot escape `FnMut` closure body
2   --> $DIR/do-not-suggest-adding-move-when-closure-is-already-marked-as-move.rs:6:9
3    |
4 LL |     let mut vec: Vec<i32> = Vec::new();
5    |         ------- variable defined here
6 LL |     let closure = move || {
7    |                         - inferred to be a `FnMut` closure
8 LL |         vec.clear();
9    |         --- variable captured here
10 LL |         let mut iter = vec.iter();
11 LL |         move || { iter.next() }
12    |         ^^^^^^^^^^^^^^^^^^^^^^^ returns a closure that contains a reference to a captured variable, which then escapes the closure body
13    |
14    = note: `FnMut` closures only have access to their captured variables while they are executing...
15    = note: ...therefore, they cannot allow references to captured variables to escape
16
17 error: aborting due to previous error
18