rust/tests/fail/stacked_borrows/fnentry_invalidation.rs
Ben Kimock 14e72e7ffa Improve information sharing across SB diagnostics
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.
2022-08-18 15:01:03 -04:00

21 lines
578 B
Rust

// Test that spans displayed in diagnostics identify the function call, not the function
// definition, as the location of invalidation due to FnEntry retag. Technically the FnEntry retag
// occurs inside the function, but what the user wants to know is which call produced the
// invalidation.
fn main() {
let mut x = 0i32;
let z = &mut x as *mut i32;
x.do_bad();
unsafe {
let _oof = *z; //~ ERROR: /read access .* tag does not exist in the borrow stack/
}
}
trait Bad {
fn do_bad(&mut self) {
// who knows
}
}
impl Bad for i32 {}