diff options
| author | bors <bors@rust-lang.org> | 2021-03-09 09:43:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-09 09:43:55 +0000 |
| commit | 3a5d45f68cadc8fff4fbb557780f92b403b19c19 (patch) | |
| tree | 2d80555f16636c76ee9e5d452078c13f19cc1f4a /library/alloc/src | |
| parent | 4b9f5cc4c10a161047475cb9bbe02c4fda57fb07 (diff) | |
| parent | 74de9db0ce515a26171c441cd808e6d872010f86 (diff) | |
Auto merge of #82929 - m-ou-se:rollup-7fwrewh, r=m-ou-se
Rollup of 8 pull requests Successful merges: - #81127 (Improve sift_down performance in BinaryHeap) - #81879 (Added #[repr(transparent)] to core::cmp::Reverse) - #82048 (or-patterns: disallow in `let` bindings) - #82731 (Bump libc dependency of std to 0.2.88.) - #82799 (Add regression test for #75525) - #82841 (Change x64 size checks to not apply to x32.) - #82883 (Update Cargo) - #82887 (Update CONTRIBUTING.md) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/collections/binary_heap.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/alloc/src/collections/binary_heap.rs b/library/alloc/src/collections/binary_heap.rs index 4377780e15f..b5e66d37ab4 100644 --- a/library/alloc/src/collections/binary_heap.rs +++ b/library/alloc/src/collections/binary_heap.rs @@ -566,7 +566,7 @@ impl<T: Ord> BinaryHeap<T> { let mut child = 2 * hole.pos() + 1; // Loop invariant: child == 2 * hole.pos() + 1. - while child < end - 1 { + while child <= end.saturating_sub(2) { // compare with the greater of the two children // SAFETY: child < end - 1 < self.len() and // child + 1 < end <= self.len(), so they're valid indexes. @@ -625,7 +625,7 @@ impl<T: Ord> BinaryHeap<T> { let mut child = 2 * hole.pos() + 1; // Loop invariant: child == 2 * hole.pos() + 1. - while child < end - 1 { + while child <= end.saturating_sub(2) { // SAFETY: child < end - 1 < self.len() and // child + 1 < end <= self.len(), so they're valid indexes. // child == 2 * hole.pos() + 1 != hole.pos() and |
