]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/stacked_borrows/illegal_write5.rs
Rollup merge of #101664 - mejrs:similarity, r=fee1-dead
[rust.git] / src / tools / miri / tests / fail / stacked_borrows / illegal_write5.rs
1 // A callee may not write to the destination of our `&mut` without us noticing.
2
3 fn main() {
4     let mut x = 15;
5     let xraw = &mut x as *mut _;
6     // Derived from raw value, so using raw value is still ok ...
7     let xref = unsafe { &mut *xraw };
8     callee(xraw);
9     // ... though any use of raw value will invalidate our ref.
10     let _val = *xref;
11     //~^ ERROR: /read access .* tag does not exist in the borrow stack/
12 }
13
14 fn callee(xraw: *mut i32) {
15     unsafe { *xraw = 15 };
16 }