Skip to content

Commit 3ec1a28

Browse files
SkiFire13Mark-Simulacrum
authored andcommitted
Add FIXME for safety comments that are invalid when T is a ZST
1 parent 9b4e612 commit 3ec1a28

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/alloc/src/collections/binary_heap.rs

+4
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@ impl<T: Ord> BinaryHeap<T> {
571571
// child + 1 < end <= self.len(), so they're valid indexes.
572572
// child == 2 * hole.pos() + 1 != hole.pos() and
573573
// child + 1 == 2 * hole.pos() + 2 != hole.pos().
574+
// FIXME: 2 * hole.pos() + 1 or 2 * hole.pos() + 2 could overflow
575+
// if T is a ZST
574576
child += unsafe { hole.get(child) <= hole.get(child + 1) } as usize;
575577

576578
// if we are already in order, stop.
@@ -627,6 +629,8 @@ impl<T: Ord> BinaryHeap<T> {
627629
// child + 1 < end <= self.len(), so they're valid indexes.
628630
// child == 2 * hole.pos() + 1 != hole.pos() and
629631
// child + 1 == 2 * hole.pos() + 2 != hole.pos().
632+
// FIXME: 2 * hole.pos() + 1 or 2 * hole.pos() + 2 could overflow
633+
// if T is a ZST
630634
child += unsafe { hole.get(child) <= hole.get(child + 1) } as usize;
631635

632636
// SAFETY: Same as above

0 commit comments

Comments
 (0)