Skip to content

Commit 0a52b43

Browse files
authored
Rollup merge of #79631 - RalfJung:miri-const_str_ptr, r=oli-obk
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.
2 parents aef5edd + 7e74b72 commit 0a52b43

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

library/alloc/tests/str.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1978,9 +1978,14 @@ fn const_str_ptr() {
19781978
const B: &'static [u8; 2] = &A;
19791979
const C: *const u8 = B as *const u8;
19801980

1981-
unsafe {
1981+
// Miri does not deduplicate consts (https://github.com/rust-lang/miri/issues/131)
1982+
#[cfg(not(miri))]
1983+
{
19821984
let foo = &A as *const u8;
19831985
assert_eq!(foo, C);
1986+
}
1987+
1988+
unsafe {
19841989
assert_eq!(from_utf8_unchecked(&A), "hi");
19851990
assert_eq!(*C, A[0]);
19861991
assert_eq!(*(&B[0] as *const u8), A[0]);

0 commit comments

Comments
 (0)