14e72e7ffa
Previous Stacked Borrows diagnostics were missing a lot of information about the state of the interpreter, and it was difficult to add additional state because it was threaded through all the intervening function signatures. This change factors a lot of the arguments which used to be passed individually to many stacked borrows functions into a single `DiagnosticCx`, which is built in `Stacks::for_each`, and since it wraps a handle to `AllocHistory`, we can now handle more nuanced things like heterogeneous borrow of `!Freeze` types.
18 lines
569 B
Rust
18 lines
569 B
Rust
use std::cell::UnsafeCell;
|
|
|
|
fn main() {
|
|
unsafe {
|
|
let c = &UnsafeCell::new(UnsafeCell::new(0));
|
|
let inner_uniq = &mut *c.get();
|
|
// stack: [c: SharedReadWrite, inner_uniq: Unique]
|
|
|
|
let inner_shr = &*inner_uniq; // adds a SharedReadWrite
|
|
// stack: [c: SharedReadWrite, inner_uniq: Unique, inner_shr: SharedReadWrite]
|
|
|
|
*c.get() = UnsafeCell::new(1); // invalidates inner_shr
|
|
// stack: [c: SharedReadWrite]
|
|
|
|
let _val = *inner_shr.get(); //~ ERROR: /retag .* tag does not exist in the borrow stack/
|
|
}
|
|
}
|