]> git.lizzy.rs Git - rust.git/blob - tests/fail/stacked_borrows/illegal_write1.rs
5bdd4ef1f052af97d2ae124b285bca2e5208e62d
[rust.git] / tests / fail / stacked_borrows / illegal_write1.rs
1 fn main() {
2     let target = Box::new(42); // has an implicit raw
3     let xref = &*target;
4     {
5         let x: *mut u32 = xref as *const _ as *mut _;
6         unsafe {
7             *x = 42;
8         } // invalidates shared ref, activates raw
9     }
10     let _x = *xref; //~ ERROR borrow stack
11 }