@@ -281,7 +281,8 @@ pub macro PartialEq($item:item) {
281
281
#[ doc( alias = "!=" ) ]
282
282
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
283
283
#[ rustc_diagnostic_item = "Eq" ]
284
- pub trait Eq : PartialEq < Self > {
284
+ #[ const_trait]
285
+ pub trait Eq : ~const PartialEq < Self > {
285
286
// this method is used solely by #[deriving] to assert
286
287
// that every component of a type implements #[deriving]
287
288
// itself, the current deriving infrastructure means doing this
@@ -331,8 +332,9 @@ pub struct AssertParamIsEq<T: Eq + ?Sized> {
331
332
/// let result = 2.cmp(&1);
332
333
/// assert_eq!(Ordering::Greater, result);
333
334
/// ```
334
- #[ derive( Clone , Copy , Eq , Debug , Hash ) ]
335
- #[ cfg_attr( not( bootstrap) , derive_const( PartialOrd , Ord , PartialEq ) ) ]
335
+ #[ derive( Clone , Copy , Debug , Hash ) ]
336
+ #[ cfg_attr( bootstrap, derive( Ord , Eq ) ) ]
337
+ #[ cfg_attr( not( bootstrap) , derive_const( PartialOrd , Ord , PartialEq , Eq ) ) ]
336
338
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
337
339
#[ repr( i8 ) ]
338
340
pub enum Ordering {
@@ -762,7 +764,7 @@ impl<T: Clone> Clone for Reverse<T> {
762
764
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
763
765
#[ rustc_diagnostic_item = "Ord" ]
764
766
#[ const_trait]
765
- pub trait Ord : Eq + PartialOrd < Self > {
767
+ pub trait Ord : ~ const Eq + ~ const PartialOrd < Self > {
766
768
/// This method returns an [`Ordering`] between `self` and `other`.
767
769
///
768
770
/// By convention, `self.cmp(&other)` returns the ordering matching the expression
@@ -892,16 +894,6 @@ impl const PartialEq for Ordering {
892
894
}
893
895
}
894
896
895
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
896
- #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
897
- #[ cfg( bootstrap) ]
898
- impl const Ord for Ordering {
899
- #[ inline]
900
- fn cmp ( & self , other : & Ordering ) -> Ordering {
901
- ( * self as i32 ) . cmp ( & ( * other as i32 ) )
902
- }
903
- }
904
-
905
897
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
906
898
#[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
907
899
#[ cfg( bootstrap) ]
@@ -1231,9 +1223,8 @@ pub const fn min<T: ~const Ord + ~const Destruct>(v1: T, v2: T) -> T {
1231
1223
#[ stable( feature = "cmp_min_max_by" , since = "1.53.0" ) ]
1232
1224
#[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
1233
1225
pub const fn min_by < T , F : ~const FnOnce ( & T , & T ) -> Ordering > ( v1 : T , v2 : T , compare : F ) -> T
1234
- where
1226
+ where
1235
1227
T : ~const Destruct ,
1236
- F : ~const Destruct ,
1237
1228
{
1238
1229
match compare ( & v1, & v2) {
1239
1230
Ordering :: Less | Ordering :: Equal => v1,
@@ -1318,8 +1309,6 @@ pub const fn max<T: ~const Ord + ~const Destruct>(v1: T, v2: T) -> T {
1318
1309
pub const fn max_by < T , F : ~const FnOnce ( & T , & T ) -> Ordering > ( v1 : T , v2 : T , compare : F ) -> T
1319
1310
where
1320
1311
T : ~const Destruct ,
1321
- F : ~const Destruct ,
1322
- {
1323
1312
match compare( & v1 , & v2 ) {
1324
1313
Ordering :: Less | Ordering :: Equal => v2,
1325
1314
Ordering :: Greater => v1,
@@ -1399,7 +1388,8 @@ mod impls {
1399
1388
macro_rules! eq_impl {
1400
1389
( $( $t: ty) * ) => ( $(
1401
1390
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1402
- impl Eq for $t { }
1391
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
1392
+ impl const Eq for $t { }
1403
1393
) * )
1404
1394
}
1405
1395
@@ -1523,7 +1513,8 @@ mod impls {
1523
1513
}
1524
1514
1525
1515
#[ unstable( feature = "never_type" , issue = "35121" ) ]
1526
- impl Eq for ! { }
1516
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
1517
+ impl const Eq for ! { }
1527
1518
1528
1519
#[ unstable( feature = "never_type" , issue = "35121" ) ]
1529
1520
#[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
0 commit comments