@@ -158,6 +158,8 @@ mod private_slice_index {
158
158
message = "the type `{T}` cannot be indexed by `{Self}`" ,
159
159
label = "slice indices are of type `usize` or ranges of `usize`"
160
160
) ]
161
+ #[ const_trait]
162
+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
161
163
pub unsafe trait SliceIndex < T : ?Sized > : private_slice_index:: Sealed {
162
164
/// The output type returned by methods.
163
165
#[ stable( feature = "slice_get_slice" , since = "1.28.0" ) ]
@@ -208,7 +210,8 @@ pub unsafe trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
208
210
209
211
/// The methods `index` and `index_mut` panic if the index is out of bounds.
210
212
#[ 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 {
212
215
type Output = T ;
213
216
214
217
#[ inline]
@@ -278,7 +281,8 @@ unsafe impl<T> SliceIndex<[T]> for usize {
278
281
279
282
/// Because `IndexRange` guarantees `start <= end`, fewer checks are needed here
280
283
/// 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 {
282
286
type Output = [ T ] ;
283
287
284
288
#[ inline]
@@ -354,7 +358,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::IndexRange {
354
358
/// - the start of the range is greater than the end of the range or
355
359
/// - the end of the range is out of bounds.
356
360
#[ 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 > {
358
363
type Output = [ T ] ;
359
364
360
365
#[ inline]
@@ -453,7 +458,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
453
458
}
454
459
455
460
#[ 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 > {
457
463
type Output = [ T ] ;
458
464
459
465
#[ inline]
@@ -491,7 +497,8 @@ unsafe impl<T> SliceIndex<[T]> for range::Range<usize> {
491
497
492
498
/// The methods `index` and `index_mut` panic if the end of the range is out of bounds.
493
499
#[ 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 > {
495
502
type Output = [ T ] ;
496
503
497
504
#[ inline]
@@ -529,7 +536,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeTo<usize> {
529
536
530
537
/// The methods `index` and `index_mut` panic if the start of the range is out of bounds.
531
538
#[ 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 > {
533
541
type Output = [ T ] ;
534
542
535
543
#[ inline]
@@ -574,7 +582,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeFrom<usize> {
574
582
}
575
583
576
584
#[ 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 > {
578
587
type Output = [ T ] ;
579
588
580
589
#[ inline]
@@ -611,7 +620,8 @@ unsafe impl<T> SliceIndex<[T]> for range::RangeFrom<usize> {
611
620
}
612
621
613
622
#[ 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 {
615
625
type Output = [ T ] ;
616
626
617
627
#[ inline]
@@ -650,7 +660,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeFull {
650
660
/// - the start of the range is greater than the end of the range or
651
661
/// - the end of the range is out of bounds.
652
662
#[ 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 > {
654
665
type Output = [ T ] ;
655
666
656
667
#[ inline]
@@ -693,7 +704,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
693
704
}
694
705
695
706
#[ 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 > {
697
709
type Output = [ T ] ;
698
710
699
711
#[ inline]
@@ -731,7 +743,8 @@ unsafe impl<T> SliceIndex<[T]> for range::RangeInclusive<usize> {
731
743
732
744
/// The methods `index` and `index_mut` panic if the end of the range is out of bounds.
733
745
#[ 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 > {
735
748
type Output = [ T ] ;
736
749
737
750
#[ inline]
0 commit comments