Skip to content

Commit

Permalink
Auto merge of rust-lang#2726 - RalfJung:provenance-test, r=RalfJung
Browse files Browse the repository at this point in the history
add provenance-related test

One of the cases in rust-lang/miri#2182 actually works as intended since rust-lang#104054 (or maybe even earlier); make sure we test that.
  • Loading branch information
bors committed Dec 11, 2022
2 parents f2ae9e5 + a4b966a commit 0876519
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/tools/miri/tests/pass/provenance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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]);
}

0 comments on commit 0876519

Please sign in to comment.