]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/stacked-borrows/unknown-bottom-gc.rs
Rollup merge of #103084 - inquisitivecrystal:control-flow, r=scottmcm
[rust.git] / src / tools / miri / tests / pass / stacked-borrows / unknown-bottom-gc.rs
1 //@compile-flags: -Zmiri-permissive-provenance
2 #![feature(strict_provenance)]
3
4 use std::ptr;
5
6 fn main() {
7     let mut v = 1u8;
8     let ptr = &mut v as *mut u8;
9
10     // Expose the allocation and use the exposed pointer, creating an unknown bottom
11     unsafe {
12         let p: *mut u8 = ptr::from_exposed_addr::<u8>(ptr.expose_addr()) as *mut u8;
13         *p = 1;
14     }
15
16     // Pile on a lot of SharedReadOnly at the top of the stack
17     let r = &v;
18     for _ in 0..1024 {
19         let _x = &*r;
20     }
21 }