Skip to content

Commit 47a1de2

Browse files
committed
Update test to make miri happy
1 parent 1c2c9bb commit 47a1de2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/hole.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -753,17 +753,18 @@ pub mod test {
753753
fn hole_list_new_min_size() {
754754
// define an array of `u64` instead of `u8` for alignment
755755
static mut HEAP: [u64; 2] = [0; 2];
756+
let heap_start = unsafe { HEAP.as_ptr() as usize };
756757
let heap =
757758
unsafe { HoleList::new(HEAP.as_mut_ptr().cast(), 2 * core::mem::size_of::<usize>()) };
758-
assert_eq!(heap.bottom.cast(), unsafe { HEAP.as_mut_ptr() });
759-
assert_eq!(heap.top.cast(), unsafe { HEAP.as_mut_ptr().add(2) });
759+
assert_eq!(heap.bottom as usize, heap_start);
760+
assert_eq!(heap.top as usize, heap_start + 2 * size_of::<usize>());
760761
assert_eq!(heap.first.size, 0); // dummy
761762
assert_eq!(
762763
heap.first.next,
763764
Some(NonNull::new(heap.bottom.cast())).unwrap()
764765
);
765766
assert_eq!(
766-
unsafe { &*(heap.first.next.unwrap().as_ptr()) }.size,
767+
unsafe { heap.first.next.as_ref().unwrap().as_ref() }.size,
767768
2 * core::mem::size_of::<usize>()
768769
);
769770
assert_eq!(unsafe { &*(heap.first.next.unwrap().as_ptr()) }.next, None);

0 commit comments

Comments
 (0)