1 error: captured variable cannot escape `FnMut` closure body
2 --> $DIR/issue-95079-missing-move-in-nested-closure.rs:3:29
4 LL | fn foo1(s: &str) -> impl Iterator<Item = String> + '_ {
5 | - variable defined here
7 LL | .flat_map(move |()| s.chars().map(|c| format!("{}{}", c, s)))
8 | - -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10 | | returns a reference to a captured variable which escapes the closure body
11 | | variable captured here
12 | inferred to be a `FnMut` closure
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 help: consider adding 'move' keyword before the nested closure
18 LL | .flat_map(move |()| s.chars().map(move |c| format!("{}{}", c, s)))
21 error: lifetime may not live long enough
22 --> $DIR/issue-95079-missing-move-in-nested-closure.rs:9:15
24 LL | move |()| s.chars().map(|c| format!("{}{}", c, s))
25 | --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2`
27 | | return type of closure `Map<Chars<'_>, [closure@$DIR/issue-95079-missing-move-in-nested-closure.rs:9:29: 9:32]>` contains a lifetime `'2`
28 | lifetime `'1` represents this closure's body
30 = note: closure implements `Fn`, so references to captured variables can't escape the closure
31 help: consider adding 'move' keyword before the nested closure
33 LL | move |()| s.chars().map(move |c| format!("{}{}", c, s))
36 error: aborting due to 2 previous errors