1 // We want to test that granting a SharedReadWrite will be added
2 // *below* an already granted SharedReadWrite -- so writing to
3 // the SharedReadWrite will invalidate the SharedReadWrite.
4 
5 use std::mem;
6 use std::cell::RefCell;
7 
main()8 fn main() { unsafe {
9     let x = &mut RefCell::new(0);
10     let y: &i32 = mem::transmute(&*x.borrow()); // launder lifetime
11     let shr_rw = &*x; // thanks to interior mutability this will be a SharedReadWrite
12     shr_rw.replace(1);
13     let _val = *y; //~ ERROR borrow stack
14 } }
15