]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/stacked_borrows/interior_mut1.rs
make writes act stack-like
[rust.git] / tests / compile-fail / stacked_borrows / interior_mut1.rs
1 use std::cell::UnsafeCell;
2
3 fn main() { unsafe {
4     let c = &UnsafeCell::new(UnsafeCell::new(0));
5     let inner_uniq = &mut *c.get();
6     let inner_shr = &*inner_uniq; // a SharedRW with a tag
7     *c.get() = UnsafeCell::new(1); // invalidates the SharedRW
8     let _val = *inner_shr.get(); //~ ERROR borrow stack
9     let _val = *inner_uniq.get();
10 } }