2017-12-06 15:19:06 -06:00
|
|
|
// As in `escape-upvar-ref.rs`, test closure that:
|
2017-11-22 16:39:46 -06:00
|
|
|
//
|
|
|
|
// - 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
|
2017-11-22 16:39:46 -06:00
|
|
|
|
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
|
|
|
|
#[rustc_regions]
|
|
|
|
fn test() {
|
|
|
|
let x = 44;
|
|
|
|
let mut p = &x;
|
|
|
|
|
|
|
|
{
|
|
|
|
let y = 22;
|
|
|
|
|
2018-08-01 15:02:10 -05:00
|
|
|
let mut closure = || {
|
|
|
|
let mut closure1 = || p = &y; //~ ERROR `y` does not live long enough [E0597]
|
2017-11-22 16:39:46 -06:00
|
|
|
closure1();
|
|
|
|
};
|
|
|
|
|
|
|
|
closure();
|
2017-12-11 11:29:31 -06:00
|
|
|
}
|
2017-11-22 16:39:46 -06:00
|
|
|
|
|
|
|
deref(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn deref(_p: &i32) { }
|
|
|
|
|
|
|
|
fn main() { }
|