diff options
| author | Giacomo Stevanato <giaco.stevanato@gmail.com> | 2021-02-12 10:50:16 +0100 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2021-02-20 15:44:17 -0500 |
| commit | 3ec1a28418472d64518efcb72e25ff976d6ff140 (patch) | |
| tree | 2a6273513e1d915c88477da138ac2ad9e24d562e | |
| parent | 9b4e61255c4112c774194e62728b4d575abfff26 (diff) | |
| download | rust-3ec1a28418472d64518efcb72e25ff976d6ff140.tar.gz rust-3ec1a28418472d64518efcb72e25ff976d6ff140.zip | |
Add FIXME for safety comments that are invalid when T is a ZST
| -rw-r--r-- | library/alloc/src/collections/binary_heap.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/library/alloc/src/collections/binary_heap.rs b/library/alloc/src/collections/binary_heap.rs index 87184f90d57..33bd98d467c 100644 --- a/library/alloc/src/collections/binary_heap.rs +++ b/library/alloc/src/collections/binary_heap.rs @@ -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 |
