Change:
I've spotted, that panic message could've provided details on what values led to this panic, instead of mentioning condition only. Generally speaking this and some other s in Vec could've been more detailed. If it's okay to step in, I'd like to offer my help. In case of I'd suggest calling this instead I find this more informative than Candidates for improval: aforementioned : : : :
Does triaging mean a green light for this suggestion?
No, I just apply the relevant labels. :)
Though this is a small change with little time required to fix, so I'd just make the PR if I were you. :)
Note: uses the same kind of assertion in (as the old check had aliasing issues). Depending on which PR lands first, we should make sure it gets the same panic message as the others.
I think it makes sense to follow the message, that is being currently printed, when trying to access element out of bounds via . Current message template is . I followed this idiom to keep it consistent.

Discussion:
#[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn swap_remove(&mut self, index: usize) -> T { <ins> #[cold] #[inline(never)] fn assert_failed(index: usize, len: usize) -> ! { panic!("swap_remove index (is {}) should be < len (is {})", index, len); } </ins> let len = self.len(); <del> assert!(index < len); </del> <ins> if !(index < len) { assert_failed(index, len); } </ins> unsafe { // We replace self[index] with the last element. Note that if the // bounds check above succeeds there must be a last element (which

/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn insert(&mut self, index: usize, element: T) { <ins> #[cold] #[inline(never)] fn assert_failed(index: usize, len: usize) -> ! { panic!("insertion index (is {}) should be <= len (is {})", index, len); } </ins> let len = self.len(); <del> assert!(index <= len); </del> <ins> if !(index <= len) { assert_failed(index, len); } </ins> // space for the new element if len == self.buf.capacity() {

/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn remove(&mut self, index: usize) -> T { <ins> #[cold] #[inline(never)] fn assert_failed(index: usize, len: usize) -> ! { panic!("removal index (is {}) should be < len (is {})", index, len); } </ins> let len = self.len(); <del> assert!(index < len); </del> <ins> if !(index < len) { assert_failed(index, len); } </ins> unsafe { // infallible let ret;

Excluded(&n) => n, Unbounded => len, }; <del> assert!(start <= end); assert!(end <= len); </del> <ins> #[cold] #[inline(never)] fn start_assert_failed(start: usize, end: usize) -> ! { panic!("start drain index (is {}) should be <= end drain index (is {})", start, end); } #[cold] #[inline(never)] fn end_assert_failed(end: usize, len: usize) -> ! { panic!("end drain index (is {}) should be <= len (is {})", end, len); } if !(start <= end) { start_assert_failed(start, end); } if !(end <= len) { end_assert_failed(end, len); } </ins> unsafe { // set self.vec length's to start, to be safe in case Drain is leaked

#[must_use = "use `.truncate()` if you don't need the other half"] #[stable(feature = "split_off", since = "1.4.0")] pub fn split_off(&mut self, at: usize) -> Self { <del> assert!(at <= self.len(), "`at` out of bounds"); </del> <ins> #[cold] #[inline(never)] fn assert_failed(at: usize, len: usize) -> ! { panic!("`at` split index (is {}) should be <= len (is {})", at, len); } if !(at <= self.len()) { assert_failed(at, self.len()); } </ins> let other_len = self.len - at; let mut other = Vec::with_capacity(other_len);