rust/tests/compile-fail-fullmir/stacked_borrows/outdated_local.rs
2018-11-16 10:01:54 +01:00

10 lines
247 B
Rust

fn main() {
let mut x = 0;
let y: *const i32 = &x;
x = 1; // this invalidates y by reactivating the lowermost uniq borrow for this local
assert_eq!(unsafe { *y }, 1); //~ ERROR does not exist on the stack
assert_eq!(x, 1);
}