2017-11-29 16:39:01 -06:00
|
|
|
// revisions: ast mir
|
|
|
|
//[mir]compile-flags: -Z borrowck=mir
|
|
|
|
|
|
|
|
fn cplusplus_mode_exceptionally_unsafe(x: &mut Option<&'static mut isize>) {
|
|
|
|
let mut z = (0, 0);
|
2017-12-11 11:29:31 -06:00
|
|
|
*x = Some(&mut z.1);
|
|
|
|
//[ast]~^ ERROR `z.1` does not live long enough [E0597]
|
|
|
|
//[mir]~^^ ERROR `z.1` does not live long enough [E0597]
|
2017-11-29 16:39:01 -06:00
|
|
|
panic!("catch me for a dangling pointer!")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
cplusplus_mode_exceptionally_unsafe(&mut None);
|
|
|
|
}
|