rust/tests/ui/nll/closure-requirements/escape-upvar-nested.rs

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

34 lines
590 B
Rust
Raw Normal View History

// As in `escape-upvar-ref.rs`, test closure that:
//
// - captures a variable `y`
// - stores reference to `y` into another, longer-lived spot
//
// except that the closure does so via a second closure.
2022-04-01 12:13:25 -05:00
// compile-flags:-Zverbose
#![feature(rustc_attrs)]
#[rustc_regions]
fn test() {
let x = 44;
let mut p = &x;
{
let y = 22;
let mut closure = || {
let mut closure1 = || p = &y; //~ ERROR `y` does not live long enough [E0597]
closure1();
};
closure();
}
deref(p);
}
fn deref(_p: &i32) { }
fn main() { }