]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs
Rollup merge of #57132 - daxpedda:master, r=steveklabnik
[rust.git] / src / test / ui / borrowck / borrowck-local-borrow-with-panic-outlives-fn.rs
1 // revisions: ast mir
2 //[mir]compile-flags: -Z borrowck=mir
3
4 fn cplusplus_mode_exceptionally_unsafe(x: &mut Option<&'static mut isize>) {
5     let mut z = (0, 0);
6     *x = Some(&mut z.1);
7     //[ast]~^ ERROR `z.1` does not live long enough [E0597]
8     //[mir]~^^ ERROR `z.1` does not live long enough [E0597]
9     panic!("catch me for a dangling pointer!")
10 }
11
12 fn main() {
13     cplusplus_mode_exceptionally_unsafe(&mut None);
14 }