]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/stacked_borrows/pass_invalid_mut.rs
Auto merge of #102169 - scottmcm:constify-some-conditions, r=thomcc
[rust.git] / src / tools / miri / tests / fail / stacked_borrows / pass_invalid_mut.rs
1 // Make sure that we cannot pass by argument a `&mut` that got already invalidated.
2 fn foo(_: &mut i32) {}
3
4 fn main() {
5     let x = &mut 42;
6     let xraw = x as *mut _;
7     let xref = unsafe { &mut *xraw };
8     let _val = unsafe { *xraw }; // invalidate xref
9     foo(xref); //~ ERROR: /retag .* tag does not exist in the borrow stack/
10 }