Skip to content

Commit

Permalink
Auto merge of #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 #2182 actually works as intended since rust-lang/rust#104054 (or maybe even earlier); make sure we test that.
  • Loading branch information
bors committed Dec 11, 2022
2 parents 0805372 + 0e89b05 commit f6937e4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 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 f6937e4

Please sign in to comment.