1 // We *can* have aliasing &RefCell<T> and &mut T, but we cannot read through the former.
2 // Else we couldn't optimize based on the assumption that `xref` below is truly unique.
4 use std::cell::RefCell;
8 let rc = RefCell::new(0);
9 let mut refmut = rc.borrow_mut();
10 let xref: &mut i32 = &mut *refmut;
11 let xshr = &rc; // creating this is ok
12 let _val = *xref; // we can even still use our mutable reference
13 mem::forget(unsafe { ptr::read(xshr) }); // but after reading through the shared ref
14 let _val = *xref; // the mutable one is dead and gone
15 //~^ ERROR does not exist on the borrow stack