about summary refs log tree commit diff
path: root/library/core/src/slice
diff options
context:
space:
mode:
authorJosh Stone <cuviper@gmail.com>2025-06-02 10:19:58 -0700
committerJosh Stone <cuviper@gmail.com>2025-06-02 10:19:58 -0700
commit19e02c82119cf25f92fe6325d7caa483fa84b4bb (patch)
treee38288c20caa0274080427449e081421d1d010af /library/core/src/slice
parent2398bd60ef526e686a38a299cc2fa991d8b3c33e (diff)
Remove bootstrap cfgs from library/
Diffstat (limited to 'library/core/src/slice')
-rw-r--r--library/core/src/slice/index.rs57
1 files changed, 4 insertions, 53 deletions
diff --git a/library/core/src/slice/index.rs b/library/core/src/slice/index.rs
index 69160a911b2..f725c3fdd94 100644
--- a/library/core/src/slice/index.rs
+++ b/library/core/src/slice/index.rs
@@ -1,6 +1,5 @@
 //! Indexing implementations for `[T]`.
 
-#[cfg(not(bootstrap))]
 use crate::intrinsics::slice_get_unchecked;
 use crate::panic::const_panic;
 use crate::ub_checks::assert_unsafe_precondition;
@@ -85,22 +84,6 @@ const fn slice_end_index_overflow_fail() -> ! {
 // Both the safe and unsafe public methods share these helpers,
 // which use intrinsics directly to get *no* extra checks.
 
-#[cfg(bootstrap)]
-#[inline(always)]
-const unsafe fn get_noubcheck<T>(ptr: *const [T], index: usize) -> *const T {
-    let ptr = ptr as *const T;
-    // SAFETY: The caller already checked these preconditions
-    unsafe { crate::intrinsics::offset(ptr, index) }
-}
-
-#[cfg(bootstrap)]
-#[inline(always)]
-const unsafe fn get_mut_noubcheck<T>(ptr: *mut [T], index: usize) -> *mut T {
-    let ptr = ptr as *mut T;
-    // SAFETY: The caller already checked these preconditions
-    unsafe { crate::intrinsics::offset(ptr, index) }
-}
-
 #[inline(always)]
 const unsafe fn get_offset_len_noubcheck<T>(
     ptr: *const [T],
@@ -231,16 +214,8 @@ unsafe impl<T> SliceIndex<[T]> for usize {
     #[inline]
     fn get(self, slice: &[T]) -> Option<&T> {
         if self < slice.len() {
-            #[cfg(bootstrap)]
-            // SAFETY: `self` is checked to be in bounds.
-            unsafe {
-                Some(&*get_noubcheck(slice, self))
-            }
-            #[cfg(not(bootstrap))]
             // SAFETY: `self` is checked to be in bounds.
-            unsafe {
-                Some(slice_get_unchecked(slice, self))
-            }
+            unsafe { Some(slice_get_unchecked(slice, self)) }
         } else {
             None
         }
@@ -249,16 +224,8 @@ unsafe impl<T> SliceIndex<[T]> for usize {
     #[inline]
     fn get_mut(self, slice: &mut [T]) -> Option<&mut T> {
         if self < slice.len() {
-            #[cfg(bootstrap)]
             // SAFETY: `self` is checked to be in bounds.
-            unsafe {
-                Some(&mut *get_mut_noubcheck(slice, self))
-            }
-            #[cfg(not(bootstrap))]
-            // SAFETY: `self` is checked to be in bounds.
-            unsafe {
-                Some(slice_get_unchecked(slice, self))
-            }
+            unsafe { Some(slice_get_unchecked(slice, self)) }
         } else {
             None
         }
@@ -280,14 +247,7 @@ unsafe impl<T> SliceIndex<[T]> for usize {
             // Use intrinsics::assume instead of hint::assert_unchecked so that we don't check the
             // precondition of this function twice.
             crate::intrinsics::assume(self < slice.len());
-            #[cfg(bootstrap)]
-            {
-                get_noubcheck(slice, self)
-            }
-            #[cfg(not(bootstrap))]
-            {
-                slice_get_unchecked(slice, self)
-            }
+            slice_get_unchecked(slice, self)
         }
     }
 
@@ -300,16 +260,7 @@ unsafe impl<T> SliceIndex<[T]> for usize {
             (this: usize = self, len: usize = slice.len()) => this < len
         );
         // SAFETY: see comments for `get_unchecked` above.
-        unsafe {
-            #[cfg(bootstrap)]
-            {
-                get_mut_noubcheck(slice, self)
-            }
-            #[cfg(not(bootstrap))]
-            {
-                slice_get_unchecked(slice, self)
-            }
-        }
+        unsafe { slice_get_unchecked(slice, self) }
     }
 
     #[inline]