]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/stacked_borrows/outdated_local.rs
ba36e43e0c5d4c39ab960bdc0bc0c9d2f2ce8aa2
[rust.git] / tests / compile-fail / stacked_borrows / outdated_local.rs
1 fn main() {
2     let mut x = 0;
3     let y: *const i32 = &x;
4     x = 1; // this invalidates y by reactivating the lowermost uniq borrow for this local
5
6     assert_eq!(unsafe { *y }, 1); //~ ERROR does not exist on the borrow stack
7
8     assert_eq!(x, 1);
9 }