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.
This commit is contained in:
Dylan DPC 2020-12-04 03:30:32 +01:00 committed by GitHub
commit 0a52b43b24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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]);