]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/stacked_borrows/fnentry_invalidation2.rs
Rollup merge of #105459 - jyn514:proc-macro-default, r=Mark-Simulacrum
[rust.git] / src / tools / miri / tests / fail / stacked_borrows / fnentry_invalidation2.rs
1 // Regression test for https://github.com/rust-lang/miri/issues/2536
2 // This tests that we don't try to back too far up the stack when selecting a span to report.
3 // We should display the as_mut_ptr() call as the location of the invalidation, not the call to
4 // inner
5
6 struct Thing<'a> {
7     sli: &'a mut [i32],
8 }
9
10 fn main() {
11     let mut t = Thing { sli: &mut [0, 1, 2] };
12     let ptr = t.sli.as_ptr();
13     inner(&mut t);
14     unsafe {
15         let _oof = *ptr; //~ ERROR: /read access .* tag does not exist in the borrow stack/
16     }
17 }
18
19 fn inner(t: &mut Thing) {
20     let _ = t.sli.as_mut_ptr();
21 }