fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1// run-rustfix 2#![allow(dead_code, path_statements)] 3fn foo1(s: &str) -> impl Iterator<Item = String> + '_ { 4 None.into_iter() 5 .flat_map(move |()| s.chars().map(move |c| format!("{}{}", c, s))) 6 //~^ ERROR captured variable cannot escape `FnMut` closure body 7 //~| HELP consider adding 'move' keyword before the nested closure 8} 9 10fn foo2(s: &str) -> impl Sized + '_ { 11 move |()| s.chars().map(move |c| format!("{}{}", c, s)) 12 //~^ ERROR lifetime may not live long enough 13 //~| HELP consider adding 'move' keyword before the nested closure 14} 15 16pub struct X; 17pub fn foo3<'a>( 18 bar: &'a X, 19) -> impl Iterator<Item = ()> + 'a { 20 Some(()).iter().flat_map(move |()| { 21 Some(()).iter().map(move |()| { bar; }) //~ ERROR captured variable cannot escape 22 //~^ HELP consider adding 'move' keyword before the nested closure 23 }) 24} 25 26fn main() {}