]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/stacked_borrows/illegal_read4.rs
Rollup merge of #101555 - jhpratt:stabilize-mixed_integer_ops, r=joshtriplett
[rust.git] / src / tools / miri / tests / fail / stacked_borrows / illegal_read4.rs
1 // Using a raw invalidates derived `&mut` even for reading.
2 fn main() {
3     let mut x = 2;
4     let xref1 = &mut x;
5     let xraw = xref1 as *mut _;
6     let xref2 = unsafe { &mut *xraw };
7     let _val = unsafe { *xraw }; // use the raw again, this invalidates xref2 *even* with the special read except for uniq refs
8     let _illegal = *xref2; //~ ERROR: /read access .* tag does not exist in the borrow stack/
9 }