]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/stacked-borrows/issue-miri-2389.rs
Merge commit 'd822110d3b5625b9dc80ccc442e06fc3cc851d76' into clippyup
[rust.git] / src / tools / miri / tests / pass / stacked-borrows / issue-miri-2389.rs
1 use std::cell::Cell;
2
3 fn main() {
4     unsafe {
5         let root0 = Cell::new(42);
6         let wildcard = &root0 as *const Cell<i32> as usize as *const Cell<i32>;
7         // empty the stack to unknown (via SRW reborrow from wildcard)
8         let _ref0 = &*wildcard;
9         // Do a non-SRW reborrow from wildcard to start building up a stack again.
10         // Now new refs start being inserted at idx 0, pushing the unique_range up.
11         let _refn = &*&*&*&*&*(wildcard.cast::<i32>());
12         // empty the stack again, but this time with unique_range.start sitting at some high index.
13         let _ref0 = &*wildcard;
14         // and do a read which tries to clear the uniques
15         wildcard.cast::<i32>().read();
16     }
17 }