Skip to content

Commit

Permalink
Rollup merge of rust-lang#63260 - RalfJung:ptr-test, r=matklad
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Centril authored Aug 5, 2019
2 parents b428453 + 90b95cf commit 2ddc0c9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/libcore/tests/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ fn test_as_ref() {
}

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

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

0 comments on commit 2ddc0c9

Please sign in to comment.