2019-05-15 17:23:26 +02:00
|
|
|
use std::cell::UnsafeCell;
|
|
|
|
|
2022-06-20 23:40:39 -07:00
|
|
|
fn main() {
|
|
|
|
unsafe {
|
|
|
|
let c = &UnsafeCell::new(UnsafeCell::new(0));
|
|
|
|
let inner_uniq = &mut *c.get();
|
|
|
|
// stack: [c: SharedReadWrite, inner_uniq: Unique]
|
2019-05-21 15:41:26 +02:00
|
|
|
|
2022-06-20 23:40:39 -07:00
|
|
|
let inner_shr = &*inner_uniq; // adds a SharedReadWrite
|
|
|
|
// stack: [c: SharedReadWrite, inner_uniq: Unique, inner_shr: SharedReadWrite]
|
2019-05-21 15:41:26 +02:00
|
|
|
|
2022-06-20 23:40:39 -07:00
|
|
|
*c.get() = UnsafeCell::new(1); // invalidates inner_shr
|
|
|
|
// stack: [c: SharedReadWrite]
|
2019-05-21 15:41:26 +02:00
|
|
|
|
2022-05-22 19:39:09 -04:00
|
|
|
let _val = *inner_shr.get(); //~ ERROR: /retag .* tag does not exist in the borrow stack/
|
2022-06-20 23:40:39 -07:00
|
|
|
}
|
|
|
|
}
|