@@ -6,9 +6,10 @@ use crate::ub_checks::assert_unsafe_precondition;
66use  crate :: { ops,  range} ; 
77
88#[ stable( feature = "rust1" ,  since = "1.0.0" ) ]  
9- impl < T ,  I >  ops:: Index < I >  for  [ T ] 
9+ #[ rustc_const_unstable( feature = "const_index" ,  issue = "143775" ) ]  
10+ impl < T ,  I >  const  ops:: Index < I >  for  [ T ] 
1011where 
11-     I :  SliceIndex < [ T ] > , 
12+     I :  ~ const   SliceIndex < [ T ] > , 
1213{ 
1314    type  Output  = I :: Output ; 
1415
1920} 
2021
2122#[ stable( feature = "rust1" ,  since = "1.0.0" ) ]  
22- impl < T ,  I >  ops:: IndexMut < I >  for  [ T ] 
23+ #[ rustc_const_unstable( feature = "const_index" ,  issue = "143775" ) ]  
24+ impl < T ,  I >  const  ops:: IndexMut < I >  for  [ T ] 
2325where 
24-     I :  SliceIndex < [ T ] > , 
26+     I :  ~ const   SliceIndex < [ T ] > , 
2527{ 
2628    #[ inline( always) ]  
2729    fn  index_mut ( & mut  self ,  index :  I )  -> & mut  I :: Output  { 
@@ -158,6 +160,8 @@ mod private_slice_index {
158160    message = "the type `{T}` cannot be indexed by `{Self}`" ,  
159161    label = "slice indices are of type `usize` or ranges of `usize`"  
160162) ] 
163+ #[ const_trait]  
164+ #[ rustc_const_unstable( feature = "const_index" ,  issue = "143775" ) ]  
161165pub  unsafe  trait  SliceIndex < T :  ?Sized > :  private_slice_index:: Sealed  { 
162166    /// The output type returned by methods. 
163167#[ stable( feature = "slice_get_slice" ,  since = "1.28.0" ) ]  
@@ -208,7 +212,8 @@ pub unsafe trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
208212
209213/// The methods `index` and `index_mut` panic if the index is out of bounds. 
210214#[ stable( feature = "slice_get_slice_impls" ,  since = "1.15.0" ) ]  
211- unsafe  impl < T >  SliceIndex < [ T ] >  for  usize  { 
215+ #[ rustc_const_unstable( feature = "const_index" ,  issue = "143775" ) ]  
216+ unsafe  impl < T >  const  SliceIndex < [ T ] >  for  usize  { 
212217    type  Output  = T ; 
213218
214219    #[ inline]  
@@ -278,7 +283,8 @@ unsafe impl<T> SliceIndex<[T]> for usize {
278283
279284/// Because `IndexRange` guarantees `start <= end`, fewer checks are needed here 
280285/// than there are for a general `Range<usize>` (which might be `100..3`). 
281- unsafe  impl < T >  SliceIndex < [ T ] >  for  ops:: IndexRange  { 
286+ #[ rustc_const_unstable( feature = "const_index" ,  issue = "143775" ) ]  
287+ unsafe  impl < T >  const  SliceIndex < [ T ] >  for  ops:: IndexRange  { 
282288    type  Output  = [ T ] ; 
283289
284290    #[ inline]  
@@ -354,7 +360,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::IndexRange {
354360/// - the start of the range is greater than the end of the range or 
355361/// - the end of the range is out of bounds. 
356362#[ stable( feature = "slice_get_slice_impls" ,  since = "1.15.0" ) ]  
357- unsafe  impl < T >  SliceIndex < [ T ] >  for  ops:: Range < usize >  { 
363+ #[ rustc_const_unstable( feature = "const_index" ,  issue = "143775" ) ]  
364+ unsafe  impl < T >  const  SliceIndex < [ T ] >  for  ops:: Range < usize >  { 
358365    type  Output  = [ T ] ; 
359366
360367    #[ inline]  
@@ -453,7 +460,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
453460} 
454461
455462#[ unstable( feature = "new_range_api" ,  issue = "125687" ) ]  
456- unsafe  impl < T >  SliceIndex < [ T ] >  for  range:: Range < usize >  { 
463+ #[ rustc_const_unstable( feature = "const_index" ,  issue = "143775" ) ]  
464+ unsafe  impl < T >  const  SliceIndex < [ T ] >  for  range:: Range < usize >  { 
457465    type  Output  = [ T ] ; 
458466
459467    #[ inline]  
@@ -491,7 +499,8 @@ unsafe impl<T> SliceIndex<[T]> for range::Range<usize> {
491499
492500/// The methods `index` and `index_mut` panic if the end of the range is out of bounds. 
493501#[ stable( feature = "slice_get_slice_impls" ,  since = "1.15.0" ) ]  
494- unsafe  impl < T >  SliceIndex < [ T ] >  for  ops:: RangeTo < usize >  { 
502+ #[ rustc_const_unstable( feature = "const_index" ,  issue = "143775" ) ]  
503+ unsafe  impl < T >  const  SliceIndex < [ T ] >  for  ops:: RangeTo < usize >  { 
495504    type  Output  = [ T ] ; 
496505
497506    #[ inline]  
@@ -529,7 +538,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeTo<usize> {
529538
530539/// The methods `index` and `index_mut` panic if the start of the range is out of bounds. 
531540#[ stable( feature = "slice_get_slice_impls" ,  since = "1.15.0" ) ]  
532- unsafe  impl < T >  SliceIndex < [ T ] >  for  ops:: RangeFrom < usize >  { 
541+ #[ rustc_const_unstable( feature = "const_index" ,  issue = "143775" ) ]  
542+ unsafe  impl < T >  const  SliceIndex < [ T ] >  for  ops:: RangeFrom < usize >  { 
533543    type  Output  = [ T ] ; 
534544
535545    #[ inline]  
@@ -574,7 +584,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeFrom<usize> {
574584} 
575585
576586#[ unstable( feature = "new_range_api" ,  issue = "125687" ) ]  
577- unsafe  impl < T >  SliceIndex < [ T ] >  for  range:: RangeFrom < usize >  { 
587+ #[ rustc_const_unstable( feature = "const_index" ,  issue = "143775" ) ]  
588+ unsafe  impl < T >  const  SliceIndex < [ T ] >  for  range:: RangeFrom < usize >  { 
578589    type  Output  = [ T ] ; 
579590
580591    #[ inline]  
@@ -611,7 +622,8 @@ unsafe impl<T> SliceIndex<[T]> for range::RangeFrom<usize> {
611622} 
612623
613624#[ stable( feature = "slice_get_slice_impls" ,  since = "1.15.0" ) ]  
614- unsafe  impl < T >  SliceIndex < [ T ] >  for  ops:: RangeFull  { 
625+ #[ rustc_const_unstable( feature = "const_index" ,  issue = "143775" ) ]  
626+ unsafe  impl < T >  const  SliceIndex < [ T ] >  for  ops:: RangeFull  { 
615627    type  Output  = [ T ] ; 
616628
617629    #[ inline]  
@@ -650,7 +662,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeFull {
650662/// - the start of the range is greater than the end of the range or 
651663/// - the end of the range is out of bounds. 
652664#[ stable( feature = "inclusive_range" ,  since = "1.26.0" ) ]  
653- unsafe  impl < T >  SliceIndex < [ T ] >  for  ops:: RangeInclusive < usize >  { 
665+ #[ rustc_const_unstable( feature = "const_index" ,  issue = "143775" ) ]  
666+ unsafe  impl < T >  const  SliceIndex < [ T ] >  for  ops:: RangeInclusive < usize >  { 
654667    type  Output  = [ T ] ; 
655668
656669    #[ inline]  
@@ -693,7 +706,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
693706} 
694707
695708#[ unstable( feature = "new_range_api" ,  issue = "125687" ) ]  
696- unsafe  impl < T >  SliceIndex < [ T ] >  for  range:: RangeInclusive < usize >  { 
709+ #[ rustc_const_unstable( feature = "const_index" ,  issue = "143775" ) ]  
710+ unsafe  impl < T >  const  SliceIndex < [ T ] >  for  range:: RangeInclusive < usize >  { 
697711    type  Output  = [ T ] ; 
698712
699713    #[ inline]  
@@ -731,7 +745,8 @@ unsafe impl<T> SliceIndex<[T]> for range::RangeInclusive<usize> {
731745
732746/// The methods `index` and `index_mut` panic if the end of the range is out of bounds. 
733747#[ stable( feature = "inclusive_range" ,  since = "1.26.0" ) ]  
734- unsafe  impl < T >  SliceIndex < [ T ] >  for  ops:: RangeToInclusive < usize >  { 
748+ #[ rustc_const_unstable( feature = "const_index" ,  issue = "143775" ) ]  
749+ unsafe  impl < T >  const  SliceIndex < [ T ] >  for  ops:: RangeToInclusive < usize >  { 
735750    type  Output  = [ T ] ; 
736751
737752    #[ inline]  
0 commit comments