Add FIXME for safety comments that are invalid when T is a ZST

This commit is contained in:
Giacomo Stevanato 2021-02-12 10:50:16 +01:00 committed by Mark Rousskov
parent 9b4e61255c
commit 3ec1a28418

View File

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