From 94a0819fe3a0d679c3042a77bfe6a2afc505daea Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:28 +0200 Subject: Adding upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- ...sue-95079-missing-move-in-nested-closure.stderr | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/test/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr (limited to 'src/test/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr') diff --git a/src/test/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr b/src/test/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr new file mode 100644 index 000000000..2eae614a2 --- /dev/null +++ b/src/test/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr @@ -0,0 +1,37 @@ +error: captured variable cannot escape `FnMut` closure body + --> $DIR/issue-95079-missing-move-in-nested-closure.rs:3:29 + | +LL | fn foo1(s: &str) -> impl Iterator + '_ { + | - variable defined here +LL | None.into_iter() +LL | .flat_map(move |()| s.chars().map(|c| format!("{}{}", c, s))) + | - -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | returns a reference to a captured variable which escapes the closure body + | | variable captured here + | inferred to be a `FnMut` closure + | + = note: `FnMut` closures only have access to their captured variables while they are executing... + = note: ...therefore, they cannot allow references to captured variables to escape +help: consider adding 'move' keyword before the nested closure + | +LL | .flat_map(move |()| s.chars().map(move |c| format!("{}{}", c, s))) + | ++++ + +error: lifetime may not live long enough + --> $DIR/issue-95079-missing-move-in-nested-closure.rs:9:15 + | +LL | move |()| s.chars().map(|c| format!("{}{}", c, s)) + | --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` + | | | + | | return type of closure `Map, [closure@$DIR/issue-95079-missing-move-in-nested-closure.rs:9:29: 9:32]>` contains a lifetime `'2` + | lifetime `'1` represents this closure's body + | + = note: closure implements `Fn`, so references to captured variables can't escape the closure +help: consider adding 'move' keyword before the nested closure + | +LL | move |()| s.chars().map(move |c| format!("{}{}", c, s)) + | ++++ + +error: aborting due to 2 previous errors + -- cgit v1.2.3