@@ -8,9 +8,10 @@ use crate::num::NonZero;
88use  crate :: ops:: ControlFlow ; 
99
1010#[ stable( feature = "rust1" ,  since = "1.0.0" ) ]  
11- impl < T ,  U >  PartialEq < [ U ] >  for  [ T ] 
11+ #[ rustc_const_unstable( feature = "const_cmp" ,  issue = "143800" ) ]  
12+ impl < T ,  U >  const  PartialEq < [ U ] >  for  [ T ] 
1213where 
13-     T :  PartialEq < U > , 
14+     T :  ~ const   PartialEq < U > , 
1415{ 
1516    fn  eq ( & self ,  other :  & [ U ] )  -> bool  { 
1617        SlicePartialEq :: equal ( self ,  other) 
@@ -94,6 +95,8 @@ impl<T: PartialOrd> PartialOrd for [T] {
9495
9596#[ doc( hidden) ]  
9697// intermediate trait for specialization of slice's PartialEq 
98+ #[ const_trait]  
99+ #[ rustc_const_unstable( feature = "const_cmp" ,  issue = "143800" ) ]  
97100trait  SlicePartialEq < B >  { 
98101    fn  equal ( & self ,  other :  & [ B ] )  -> bool ; 
99102
@@ -103,9 +106,10 @@ trait SlicePartialEq<B> {
103106} 
104107
105108// Generic slice equality 
106- impl < A ,  B >  SlicePartialEq < B >  for  [ A ] 
109+ #[ rustc_const_unstable( feature = "const_cmp" ,  issue = "143800" ) ]  
110+ impl < A ,  B >  const  SlicePartialEq < B >  for  [ A ] 
107111where 
108-     A :  PartialEq < B > , 
112+     A :  ~ const   PartialEq < B > , 
109113{ 
110114    default  fn  equal ( & self ,  other :  & [ B ] )  -> bool  { 
111115        if  self . len ( )  != other. len ( )  { 
@@ -115,11 +119,13 @@ where
115119        // Implemented as explicit indexing rather 
116120        // than zipped iterators for performance reasons. 
117121        // See PR https://github.com/rust-lang/rust/pull/116846 
118-         for  idx in  0 ..self . len ( )  { 
122+         let  mut  idx = 0 ; 
123+         while  idx < self . len ( )  { 
119124            // bound checks are optimized away 
120125            if  self [ idx]  != other[ idx]  { 
121126                return  false ; 
122127            } 
128+             idx += 1 ; 
123129        } 
124130
125131        true 
@@ -128,9 +134,10 @@ where
128134
129135// When each element can be compared byte-wise, we can compare all the bytes 
130136// from the whole size in one call to the intrinsics. 
131- impl < A ,  B >  SlicePartialEq < B >  for  [ A ] 
137+ #[ rustc_const_unstable( feature = "const_cmp" ,  issue = "143800" ) ]  
138+ impl < A ,  B >  const  SlicePartialEq < B >  for  [ A ] 
132139where 
133-     A :  BytewiseEq < B > , 
140+     A :  ~ const   BytewiseEq < B > , 
134141{ 
135142    fn  equal ( & self ,  other :  & [ B ] )  -> bool  { 
136143        if  self . len ( )  != other. len ( )  { 
0 commit comments