rust/tests/compile-fail/stacked_borrows/outdated_local.rs
Ralf Jung ef52be031c adjust compile-fail error messages
This also passes miri-test-libstd!
2019-04-17 16:02:57 +02:00

10 lines
232 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 borrow stack
assert_eq!(x, 1);
}