rust/tests/compile-fail/stacked_borrows/illegal_write1.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
272 B
Rust

fn main() {
let target = Box::new(42); // has an implicit raw
let xref = &*target;
{
let x : *mut u32 = xref as *const _ as *mut _;
unsafe { *x = 42; } // invalidates shared ref, activates raw
}
let _x = *xref; //~ ERROR borrow stack
}