Skip to content

Commit

Permalink
Rollup merge of #79631 - RalfJung:miri-const_str_ptr, r=oli-obk
Browse files Browse the repository at this point in the history
disable a ptr equality test on Miri

This test relies on deduplication of constants. I do not think that this is a *guarantee* that Rust currently makes, and indeed Miri does not deduplicate constants the same way that rustc does, leading to different behavior in this test.

For now, I propose we simply disable this test in Miri.
  • Loading branch information
GuillaumeGomez authored Dec 3, 2020
2 parents 954a1d8 + 7e74b72 commit 788aa3a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion library/alloc/tests/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1978,9 +1978,14 @@ fn const_str_ptr() {
const B: &'static [u8; 2] = &A;
const C: *const u8 = B as *const u8;

unsafe {
// Miri does not deduplicate consts (https://github.com/rust-lang/miri/issues/131)
#[cfg(not(miri))]
{
let foo = &A as *const u8;
assert_eq!(foo, C);
}

unsafe {
assert_eq!(from_utf8_unchecked(&A), "hi");
assert_eq!(*C, A[0]);
assert_eq!(*(&B[0] as *const u8), A[0]);
Expand Down

0 comments on commit 788aa3a

Please sign in to comment.