rust/tests/ui/regions/regions-nested-fns.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
618 B
Rust
Raw Normal View History

fn ignore<T>(t: T) {}
fn nested<'x>(x: &'x isize) {
let y = 3;
let mut ay = &y;
2022-04-01 17:13:25 +00:00
//~^ ERROR `y` does not live long enough [E0597]
2019-05-28 18:46:13 +00:00
ignore::<Box<dyn for<'z> FnMut(&'z isize)>>(Box::new(|z| {
ay = x;
2013-03-15 19:24:24 +00:00
ay = &y;
2022-04-01 17:13:25 +00:00
//~^ ERROR `y` does not live long enough
ay = z;
2022-04-01 17:13:25 +00:00
//~^ ERROR borrowed data escapes outside of closure [E0521]
}));
2019-05-28 18:46:13 +00:00
ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
if false { return x; }
2022-04-01 17:13:25 +00:00
//~^ ERROR lifetime may not live long enough
if false { return ay; }
2012-08-02 00:30:05 +00:00
return z;
}));
}
fn main() {}