]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/stacked_borrows/exposed_only_ro.rs
Rollup merge of #102187 - b-naber:inline-const-source-info, r=eholk
[rust.git] / src / tools / miri / tests / fail / stacked_borrows / exposed_only_ro.rs
1 //@compile-flags: -Zmiri-permissive-provenance
2 #![feature(strict_provenance)]
3
4 // If we have only exposed read-only pointers, doing a write through a wildcard ptr should fail.
5
6 fn main() {
7     let mut x = 0;
8     let _fool = &mut x as *mut i32; // this would have fooled the old untagged pointer logic
9     let addr = (&x as *const i32).expose_addr();
10     let ptr = std::ptr::from_exposed_addr_mut::<i32>(addr);
11     unsafe { *ptr = 0 }; //~ ERROR: /write access using <wildcard> .* no exposed tags have suitable permission in the borrow stack/
12 }