Auto merge of #2726 - RalfJung:provenance-test, r=RalfJung

add provenance-related test

One of the cases in https://github.com/rust-lang/miri/issues/2182 actually works as intended since https://github.com/rust-lang/rust/pull/104054 (or maybe even earlier); make sure we test that.
This commit is contained in:
bors 2022-12-11 22:05:56 +00:00
commit 0876519fe3

View file

@ -10,6 +10,7 @@ fn main() {
bytewise_ptr_methods();
bytewise_custom_memcpy();
bytewise_custom_memcpy_chunked();
int_load_strip_provenance();
}
/// Some basic smoke tests for provenance.
@ -137,3 +138,9 @@ fn bytewise_custom_memcpy_chunked() {
assert_eq!(*ptr, 42);
}
}
fn int_load_strip_provenance() {
let ptrs = [&42];
let ints: [usize; 1] = unsafe { mem::transmute(ptrs) };
assert_eq!(ptrs[0] as *const _ as usize, ints[0]);
}