about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libcore/slice.rs8
-rw-r--r--src/test/run-fail/bounds-check-no-overflow.rs2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs
index b22bdb43414..97556233659 100644
--- a/src/libcore/slice.rs
+++ b/src/libcore/slice.rs
@@ -520,8 +520,8 @@ impl<T> ops::Index<usize> for [T] {
     type Output = T;
 
     fn index(&self, index: usize) -> &T {
-        assert!(index < self.len());
-        unsafe { self.get_unchecked(index) }
+        // NB built-in indexing
+        &(*self)[index]
     }
 }
 
@@ -530,8 +530,8 @@ impl<T> ops::Index<usize> for [T] {
 impl<T> ops::IndexMut<usize> for [T] {
     #[inline]
     fn index_mut(&mut self, index: usize) -> &mut T {
-        assert!(index < self.len());
-        unsafe { self.get_unchecked_mut(index) }
+        // NB built-in indexing
+        &mut (*self)[index]
     }
 }
 
diff --git a/src/test/run-fail/bounds-check-no-overflow.rs b/src/test/run-fail/bounds-check-no-overflow.rs
index 4d502cb2106..3d1cbb446e8 100644
--- a/src/test/run-fail/bounds-check-no-overflow.rs
+++ b/src/test/run-fail/bounds-check-no-overflow.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:assertion failed: index < self.len()
+// error-pattern:index out of bounds
 
 use std::usize;
 use std::mem::size_of;