]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/stacked_borrows/load_invalid_mut.rs
adjust compile-fail error messages
[rust.git] / tests / compile-fail / stacked_borrows / load_invalid_mut.rs
1 // Make sure that we cannot load from memory a `&mut` that got already invalidated.
2 fn main() {
3     let x = &mut 42;
4     let xraw = x as *mut _;
5     let xref = unsafe { &mut *xraw };
6     let xref_in_mem = Box::new(xref);
7     let _val = unsafe { *xraw }; // invalidate xref
8     let _val = *xref_in_mem; //~ ERROR borrow stack
9 }