File tree Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -560,8 +560,8 @@ impl<T> [T] {
560
560
#[stable(feature = "rust1", since = "1.0.0")]
561
561
#[inline]
562
562
pub fn swap(&mut self, a: usize, b: usize) {
563
- assert_in_bounds(self.len(), a) ;
564
- assert_in_bounds(self.len(), b) ;
563
+ let _ = &self[a] ;
564
+ let _ = &self[b] ;
565
565
566
566
// SAFETY: we just checked that both `a` and `b` are in bounds
567
567
unsafe { self.swap_unchecked(a, b) }
@@ -598,8 +598,8 @@ impl<T> [T] {
598
598
pub unsafe fn swap_unchecked(&mut self, a: usize, b: usize) {
599
599
#[cfg(debug_assertions)]
600
600
{
601
- assert_in_bounds(self.len(), a) ;
602
- assert_in_bounds(self.len(), b) ;
601
+ let _ = &self[a] ;
602
+ let _ = &self[b] ;
603
603
}
604
604
605
605
let ptr = self.as_mut_ptr();
@@ -3502,12 +3502,6 @@ impl<T> [T] {
3502
3502
}
3503
3503
}
3504
3504
3505
- fn assert_in_bounds(len: usize, idx: usize) {
3506
- if idx >= len {
3507
- panic!("index out of bounds: the len is {} but the index is {}", len, idx);
3508
- }
3509
- }
3510
-
3511
3505
trait CloneFromSpec<T> {
3512
3506
fn spec_clone_from(&mut self, src: &[T]);
3513
3507
}
You can’t perform that action at this time.
0 commit comments