@@ -158,6 +158,8 @@ mod private_slice_index {
158158 message = "the type `{T}` cannot be indexed by `{Self}`" ,
159159 label = "slice indices are of type `usize` or ranges of `usize`"
160160) ]
161+ #[ const_trait]
162+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
161163pub unsafe trait SliceIndex < T : ?Sized > : private_slice_index:: Sealed {
162164 /// The output type returned by methods.
163165 #[ stable( feature = "slice_get_slice" , since = "1.28.0" ) ]
@@ -208,7 +210,8 @@ pub unsafe trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
208210
209211/// The methods `index` and `index_mut` panic if the index is out of bounds.
210212#[ stable( feature = "slice_get_slice_impls" , since = "1.15.0" ) ]
211- unsafe impl < T > SliceIndex < [ T ] > for usize {
213+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
214+ unsafe impl < T > const SliceIndex < [ T ] > for usize {
212215 type Output = T ;
213216
214217 #[ inline]
@@ -278,7 +281,8 @@ unsafe impl<T> SliceIndex<[T]> for usize {
278281
279282/// Because `IndexRange` guarantees `start <= end`, fewer checks are needed here
280283/// than there are for a general `Range<usize>` (which might be `100..3`).
281- unsafe impl < T > SliceIndex < [ T ] > for ops:: IndexRange {
284+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
285+ unsafe impl < T > const SliceIndex < [ T ] > for ops:: IndexRange {
282286 type Output = [ T ] ;
283287
284288 #[ inline]
@@ -354,7 +358,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::IndexRange {
354358/// - the start of the range is greater than the end of the range or
355359/// - the end of the range is out of bounds.
356360#[ stable( feature = "slice_get_slice_impls" , since = "1.15.0" ) ]
357- unsafe impl < T > SliceIndex < [ T ] > for ops:: Range < usize > {
361+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
362+ unsafe impl < T > const SliceIndex < [ T ] > for ops:: Range < usize > {
358363 type Output = [ T ] ;
359364
360365 #[ inline]
@@ -453,7 +458,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
453458}
454459
455460#[ unstable( feature = "new_range_api" , issue = "125687" ) ]
456- unsafe impl < T > SliceIndex < [ T ] > for range:: Range < usize > {
461+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
462+ unsafe impl < T > const SliceIndex < [ T ] > for range:: Range < usize > {
457463 type Output = [ T ] ;
458464
459465 #[ inline]
@@ -491,7 +497,8 @@ unsafe impl<T> SliceIndex<[T]> for range::Range<usize> {
491497
492498/// The methods `index` and `index_mut` panic if the end of the range is out of bounds.
493499#[ stable( feature = "slice_get_slice_impls" , since = "1.15.0" ) ]
494- unsafe impl < T > SliceIndex < [ T ] > for ops:: RangeTo < usize > {
500+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
501+ unsafe impl < T > const SliceIndex < [ T ] > for ops:: RangeTo < usize > {
495502 type Output = [ T ] ;
496503
497504 #[ inline]
@@ -529,7 +536,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeTo<usize> {
529536
530537/// The methods `index` and `index_mut` panic if the start of the range is out of bounds.
531538#[ stable( feature = "slice_get_slice_impls" , since = "1.15.0" ) ]
532- unsafe impl < T > SliceIndex < [ T ] > for ops:: RangeFrom < usize > {
539+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
540+ unsafe impl < T > const SliceIndex < [ T ] > for ops:: RangeFrom < usize > {
533541 type Output = [ T ] ;
534542
535543 #[ inline]
@@ -574,7 +582,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeFrom<usize> {
574582}
575583
576584#[ unstable( feature = "new_range_api" , issue = "125687" ) ]
577- unsafe impl < T > SliceIndex < [ T ] > for range:: RangeFrom < usize > {
585+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
586+ unsafe impl < T > const SliceIndex < [ T ] > for range:: RangeFrom < usize > {
578587 type Output = [ T ] ;
579588
580589 #[ inline]
@@ -611,7 +620,8 @@ unsafe impl<T> SliceIndex<[T]> for range::RangeFrom<usize> {
611620}
612621
613622#[ stable( feature = "slice_get_slice_impls" , since = "1.15.0" ) ]
614- unsafe impl < T > SliceIndex < [ T ] > for ops:: RangeFull {
623+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
624+ unsafe impl < T > const SliceIndex < [ T ] > for ops:: RangeFull {
615625 type Output = [ T ] ;
616626
617627 #[ inline]
@@ -650,7 +660,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeFull {
650660/// - the start of the range is greater than the end of the range or
651661/// - the end of the range is out of bounds.
652662#[ stable( feature = "inclusive_range" , since = "1.26.0" ) ]
653- unsafe impl < T > SliceIndex < [ T ] > for ops:: RangeInclusive < usize > {
663+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
664+ unsafe impl < T > const SliceIndex < [ T ] > for ops:: RangeInclusive < usize > {
654665 type Output = [ T ] ;
655666
656667 #[ inline]
@@ -693,7 +704,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
693704}
694705
695706#[ unstable( feature = "new_range_api" , issue = "125687" ) ]
696- unsafe impl < T > SliceIndex < [ T ] > for range:: RangeInclusive < usize > {
707+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
708+ unsafe impl < T > const SliceIndex < [ T ] > for range:: RangeInclusive < usize > {
697709 type Output = [ T ] ;
698710
699711 #[ inline]
@@ -731,7 +743,8 @@ unsafe impl<T> SliceIndex<[T]> for range::RangeInclusive<usize> {
731743
732744/// The methods `index` and `index_mut` panic if the end of the range is out of bounds.
733745#[ stable( feature = "inclusive_range" , since = "1.26.0" ) ]
734- unsafe impl < T > SliceIndex < [ T ] > for ops:: RangeToInclusive < usize > {
746+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
747+ unsafe impl < T > const SliceIndex < [ T ] > for ops:: RangeToInclusive < usize > {
735748 type Output = [ T ] ;
736749
737750 #[ inline]
0 commit comments