1 // ignore-compare-mode-nll
3 // Test that the borrow checker prevents pointers to temporaries
4 // with statement lifetimes from escaping.
8 static mut FLAGS: u64 = 0;
10 struct Box<T> { f: T }
11 struct AddFlags { bits: u64 }
13 fn AddFlags(bits: u64) -> AddFlags {
14 AddFlags { bits: bits }
17 fn arg(x: &AddFlags) -> &AddFlags {
22 fn get(&self) -> &AddFlags {
28 let _x = arg(&AddFlags(1)); //~ ERROR value does not live long enough
29 let _x = AddFlags(1).get(); //~ ERROR value does not live long enough
30 let _x = &*arg(&AddFlags(1)); //~ ERROR value does not live long enough
31 let ref _x = *arg(&AddFlags(1)); //~ ERROR value does not live long enough
32 let &ref _x = arg(&AddFlags(1)); //~ ERROR value does not live long enough
33 let _x = AddFlags(1).get(); //~ ERROR value does not live long enough
34 let Box { f: _x } = Box { f: AddFlags(1).get() }; //~ ERROR value does not live long enough