rust/tests/compile-fail/stacked_borrows/illegal_write2.rs

11 lines
328 B
Rust
Raw Normal View History

#![allow(unused_variables)]
fn main() {
let target = &mut 42;
let target2 = target as *mut _;
drop(&mut *target); // reborrow
// Now make sure our ref is still the only one
unsafe { *target2 = 13; } // invalidate our ref
let _val = *target; //~ ERROR Mut reference with non-reactivatable tag Mut(Uniq
}