rust/tests/fail/stacked_borrows/outdated_local.rs

10 lines
276 B
Rust
Raw Normal View History

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
2022-07-13 17:59:33 -05:00
assert_eq!(unsafe { *y }, 1); //~ ERROR: /read access .* tag does not exist in the borrow stack/
assert_eq!(x, 1);
}