rust/tests/fail/stacked_borrows/illegal_write2.rs

9 lines
286 B
Rust
Raw Normal View History

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.
2022-07-13 17:59:33 -05:00
unsafe { *target2 = 13 }; //~ ERROR: /write access .* tag does not exist in the borrow stack/
let _val = *target;
}