From 4f9fe856a25ab29345b90e7725509e9ee38a37be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:41 +0200 Subject: Adding upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- ...ssue-95079-missing-move-in-nested-closure.fixed | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.fixed (limited to 'tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.fixed') diff --git a/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.fixed b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.fixed new file mode 100644 index 000000000..1a0847006 --- /dev/null +++ b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.fixed @@ -0,0 +1,26 @@ +// run-rustfix +#![allow(dead_code, path_statements)] +fn foo1(s: &str) -> impl Iterator + '_ { + None.into_iter() + .flat_map(move |()| s.chars().map(move |c| format!("{}{}", c, s))) + //~^ ERROR captured variable cannot escape `FnMut` closure body + //~| HELP consider adding 'move' keyword before the nested closure +} + +fn foo2(s: &str) -> impl Sized + '_ { + move |()| s.chars().map(move |c| format!("{}{}", c, s)) + //~^ ERROR lifetime may not live long enough + //~| HELP consider adding 'move' keyword before the nested closure +} + +pub struct X; +pub fn foo3<'a>( + bar: &'a X, +) -> impl Iterator + 'a { + Some(()).iter().flat_map(move |()| { + Some(()).iter().map(move |()| { bar; }) //~ ERROR captured variable cannot escape + //~^ HELP consider adding 'move' keyword before the nested closure + }) +} + +fn main() {} -- cgit v1.2.3