]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/stacked_borrows/illegal_read_despite_exposed1.rs
Rollup merge of #105427 - GuillaumeGomez:dont-silently-ignore-rustdoc-errors, r=notriddle
[rust.git] / src / tools / miri / tests / fail / stacked_borrows / illegal_read_despite_exposed1.rs
1 //@compile-flags: -Zmiri-permissive-provenance
2
3 fn main() {
4     unsafe {
5         let root = &mut 42;
6         let addr = root as *mut i32 as usize;
7         let exposed_ptr = addr as *mut i32;
8         // From the exposed ptr, we get a new unique ptr.
9         let root2 = &mut *exposed_ptr;
10         let _fool = root2 as *mut _; // this would have fooled the old untagged pointer logic
11         // Stack: Unknown(<N), Unique(N), SRW(N+1)
12         // And we test that it has uniqueness by doing a conflicting write.
13         *exposed_ptr = 0;
14         // Stack: Unknown(<N)
15         let _val = *root2; //~ ERROR: /read access .* tag does not exist in the borrow stack/
16     }
17 }