1 // Creating a shared reference does not leak the data to raw pointers,
2 // not even when interior mutability is involved.
9 let x = &mut Cell::new(0);
10 let raw = x as *mut Cell<i32>;
13 // The state here is interesting because the top of the stack is [Unique, SharedReadWrite],
14 // just like if we had done `x as *mut _`.
15 // If we said that reading from a lower item is fine if the top item is `SharedReadWrite`
16 // (one way to maybe preserve a stack discipline), then we could now read from `raw`
17 // without invalidating `x`. That would be bad! It would mean that creating `shr`
18 // leaked `x` to `raw`.
19 let _val = ptr::read(raw);
20 let _val = *x.get_mut(); //~ ERROR: /retag .* tag does not exist in the borrow stack/