Skip to content

Commit 7a0dd84

Browse files
authored
Rollup merge of rust-lang#63260 - RalfJung:ptr-test, r=matklad
fix UB in a test We used to compare two mutable references that were supposed to point to the same thing. That's no good. Compare them as raw pointers instead.
2 parents 845bc4f + 90b95cf commit 7a0dd84

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/libcore/tests/ptr.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ fn test_as_ref() {
145145
}
146146

147147
#[test]
148-
#[cfg(not(miri))] // This test is UB according to Stacked Borrows
149148
fn test_as_mut() {
150149
unsafe {
151150
let p: *mut isize = null_mut();
@@ -164,7 +163,7 @@ fn test_as_mut() {
164163
// Pointers to unsized types -- slices
165164
let s: &mut [u8] = &mut [1, 2, 3];
166165
let ms: *mut [u8] = s;
167-
assert_eq!(ms.as_mut(), Some(s));
166+
assert_eq!(ms.as_mut(), Some(&mut [1, 2, 3][..]));
168167

169168
let mz: *mut [u8] = &mut [];
170169
assert_eq!(mz.as_mut(), Some(&mut [][..]));

0 commit comments

Comments
 (0)