Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit db43ee5

Browse files
committed
defend test against overly smart Miri
1 parent 2e3da5d commit db43ee5

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

tests/fail/stacked_borrows/disable_mut_does_not_merge_srw.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ fn main() {
55
unsafe {
66
let mut mem = 0;
77
let base = &mut mem as *mut i32; // the base pointer we build the rest of the stack on
8-
let mutref = &mut *base;
9-
let raw = mutref as *mut i32;
10-
// in the stack, we now have [base, mutref, raw]
8+
let raw = {
9+
let mutref = &mut *base;
10+
mutref as *mut i32
11+
};
12+
// In the stack, we now have [base, mutref, raw].
13+
// We do this in a weird way where `mutref` is out of scope here, just in case
14+
// Miri decides to get smart and argue that items for tags that are no longer
15+
// used by any pointer stored anywhere in the machine can be removed.
1116
let _val = *base;
1217
// now mutref is disabled
1318
*base = 1;

tests/fail/stacked_borrows/disable_mut_does_not_merge_srw.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ LL | let _val = *raw;
1212
help: <TAG> was created by a retag at offsets [0x0..0x4]
1313
--> $DIR/disable_mut_does_not_merge_srw.rs:LL:CC
1414
|
15-
LL | let raw = mutref as *mut i32;
16-
| ^^^^^^
15+
LL | mutref as *mut i32
16+
| ^^^^^^
1717
help: <TAG> was later invalidated at offsets [0x0..0x4]
1818
--> $DIR/disable_mut_does_not_merge_srw.rs:LL:CC
1919
|

0 commit comments

Comments
 (0)