]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/stacked_borrows/shared_rw_borrows_are_weak1.rs
Auto merge of #104915 - weihanglo:update-cargo, r=ehuss
[rust.git] / src / tools / miri / tests / fail / stacked_borrows / shared_rw_borrows_are_weak1.rs
1 // We want to test that granting a SharedReadWrite will be added
2 // *below* an already granted Unique -- so writing to
3 // the SharedReadWrite will invalidate the Unique.
4
5 use std::cell::Cell;
6 use std::mem;
7
8 fn main() {
9     unsafe {
10         let x = &mut Cell::new(0);
11         let y: &mut Cell<i32> = mem::transmute(&mut *x); // launder lifetime
12         let shr_rw = &*x; // thanks to interior mutability this will be a SharedReadWrite
13         shr_rw.set(1);
14         y.get_mut(); //~ ERROR: /retag .* tag does not exist in the borrow stack/
15     }
16 }