]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/stacked_borrows/load_invalid_mut.rs
Rollup merge of #100451 - hovinen:no-panic-on-result-err-in-test, r=Mark-Simulacrum
[rust.git] / src / tools / miri / tests / fail / stacked_borrows / load_invalid_mut.rs
1 // Make sure we catch this even without validation
2 //@compile-flags: -Zmiri-disable-validation
3
4 // Make sure that we cannot load from memory a `&mut` that got already invalidated.
5 fn main() {
6     let x = &mut 42;
7     let xraw = x as *mut _;
8     let xref = unsafe { &mut *xraw };
9     let xref_in_mem = Box::new(xref);
10     let _val = unsafe { *xraw }; // invalidate xref
11     let _val = *xref_in_mem; //~ ERROR: /retag .* tag does not exist in the borrow stack/
12 }