From 91cead3cb081f34661ef940b5a911a6e3ba7bbcf Mon Sep 17 00:00:00 2001 From: Peter Szilvasi Date: Fri, 24 Jul 2026 08:29:56 +0000 Subject: [PATCH 1/2] Update expect message using the recommended style in binary_heap module --- library/alloc/src/collections/binary_heap/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/alloc/src/collections/binary_heap/mod.rs b/library/alloc/src/collections/binary_heap/mod.rs index 34de563fe4f33..98192e1fb5b01 100644 --- a/library/alloc/src/collections/binary_heap/mod.rs +++ b/library/alloc/src/collections/binary_heap/mod.rs @@ -1258,7 +1258,7 @@ impl BinaryHeap { /// /// Ok(heap.pop()) /// } - /// # find_max_slow(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?"); + /// # find_max_slow(&[1, 2, 3]).expect("reserving capacity for 12 bytes should never fail"); /// ``` #[stable(feature = "try_reserve_2", since = "1.63.0")] pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> { @@ -1294,7 +1294,7 @@ impl BinaryHeap { /// /// Ok(heap.pop()) /// } - /// # find_max_slow(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?"); + /// # find_max_slow(&[1, 2, 3]).expect("reserving capacity for 12 bytes should never fail"); /// ``` #[stable(feature = "try_reserve_2", since = "1.63.0")] pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> { From c46ab28fc3d4876b7be58c2bab8efff05412c07d Mon Sep 17 00:00:00 2001 From: Peter Szilvasi Date: Sun, 26 Jul 2026 13:35:11 +0000 Subject: [PATCH 2/2] Update expect message in library/alloc/src/collections/vec_deque/mod.rs --- library/alloc/src/collections/vec_deque/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 9eac8bcde1d1c..9ec82c383e6c7 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -1105,7 +1105,7 @@ impl VecDeque { #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "vecdeque_reserve")] pub fn reserve(&mut self, additional: usize) { - let new_cap = self.len.checked_add(additional).expect("capacity overflow"); + let new_cap = self.len.checked_add(additional).expect("length should not overflow usize"); let old_cap = self.capacity(); if new_cap > old_cap { @@ -1153,7 +1153,7 @@ impl VecDeque { /// /// Ok(output) /// } - /// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?"); + /// # process_data(&[1, 2, 3]).expect("reserving capacity for 12 bytes should never fail"); /// ``` #[stable(feature = "try_reserve", since = "1.57.0")] pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> { @@ -1201,7 +1201,7 @@ impl VecDeque { /// /// Ok(output) /// } - /// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?"); + /// # process_data(&[1, 2, 3]).expect("reserving capacity for 12 bytes should never fail"); /// ``` #[stable(feature = "try_reserve", since = "1.57.0")] pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> { @@ -2732,7 +2732,7 @@ impl VecDeque { #[stable(feature = "append", since = "1.4.0")] pub fn append(&mut self, other: &mut Self) { if T::IS_ZST { - self.len = self.len.checked_add(other.len).expect("capacity overflow"); + self.len = self.len.checked_add(other.len).expect("length should not overflow usize"); other.len = 0; other.head = WrappedIndex::zero(); return; @@ -3871,7 +3871,7 @@ impl Index for VecDeque { #[inline] fn index(&self, index: usize) -> &T { - self.get(index).expect("Out of bounds access") + self.get(index).expect("index should be within bounds") } } @@ -3879,7 +3879,7 @@ impl Index for VecDeque { impl IndexMut for VecDeque { #[inline] fn index_mut(&mut self, index: usize) -> &mut T { - self.get_mut(index).expect("Out of bounds access") + self.get_mut(index).expect("index should be within bounds") } }