Files
rust/src/test/ui/regions/regions-nested-fns.rs

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

31 lines
788 B
Rust
Raw Normal View History

// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
fn ignore<T>(t: T) {}
fn nested<'x>(x: &'x isize) {
let y = 3;
let mut ay = &y;
//[base]~^ ERROR E0495
//[nll]~^^ ERROR `y` does not live long enough [E0597]
2019-05-28 14:46:13 -04:00
ignore::<Box<dyn for<'z> FnMut(&'z isize)>>(Box::new(|z| {
ay = x;
2013-03-15 15:24:24 -04:00
ay = &y;
//[nll]~^ ERROR `y` does not live long enough
ay = z;
//[nll]~^ ERROR borrowed data escapes outside of closure [E0521]
}));
2019-05-28 14:46:13 -04:00
ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
if false { return x; }
//[base]~^ ERROR E0312
//[nll]~^^ ERROR lifetime may not live long enough
if false { return ay; }
2012-08-01 17:30:05 -07:00
return z;
}));
}
fn main() {}