@@ -279,7 +279,8 @@ pub macro PartialEq($item:item) {
279
279
#[ doc( alias = "!=" ) ]
280
280
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
281
281
#[ rustc_diagnostic_item = "Eq" ]
282
- pub trait Eq : PartialEq < Self > {
282
+ #[ const_trait]
283
+ pub trait Eq : ~const PartialEq < Self > {
283
284
// this method is used solely by #[deriving] to assert
284
285
// that every component of a type implements #[deriving]
285
286
// itself, the current deriving infrastructure means doing this
@@ -329,8 +330,8 @@ pub struct AssertParamIsEq<T: Eq + ?Sized> {
329
330
/// let result = 2.cmp(&1);
330
331
/// assert_eq!(Ordering::Greater, result);
331
332
/// ```
332
- #[ derive( Clone , Copy , Eq , Debug , Hash ) ]
333
- #[ derive_const( PartialOrd , Ord , PartialEq ) ]
333
+ #[ derive( Clone , Copy , Debug , Hash ) ]
334
+ #[ derive_const( PartialOrd , Eq , Ord , PartialEq ) ]
334
335
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
335
336
#[ repr( i8 ) ]
336
337
pub enum Ordering {
@@ -594,11 +595,25 @@ impl Ordering {
594
595
/// v.sort_by_key(|&num| (num > 3, Reverse(num)));
595
596
/// assert_eq!(v, vec![3, 2, 1, 6, 5, 4]);
596
597
/// ```
597
- #[ derive( PartialEq , Eq , Debug , Copy , Default , Hash ) ]
598
+ #[ derive( Debug , Copy , Default , Hash ) ]
599
+ #[ cfg_attr( not( bootstrap) , derive_const( PartialEq , Eq ) ) ]
598
600
#[ stable( feature = "reverse_cmp_key" , since = "1.19.0" ) ]
599
601
#[ repr( transparent) ]
600
602
pub struct Reverse < T > ( #[ stable( feature = "reverse_cmp_key" , since = "1.19.0" ) ] pub T ) ;
601
603
604
+ #[ cfg( bootstrap) ]
605
+ #[ stable( feature = "reverse_cmp_key" , since = "1.19.0" ) ]
606
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
607
+ impl < T : ~const PartialEq > const PartialEq for Reverse < T > {
608
+ fn eq ( & self , other : & Self ) -> bool {
609
+ self . 0 == other. 0
610
+ }
611
+ }
612
+ #[ cfg( bootstrap) ]
613
+ #[ stable( feature = "reverse_cmp_key" , since = "1.19.0" ) ]
614
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
615
+ impl < T : ~const Eq > const Eq for Reverse < T > { }
616
+
602
617
#[ stable( feature = "reverse_cmp_key" , since = "1.19.0" ) ]
603
618
#[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
604
619
impl < T : ~const PartialOrd > const PartialOrd for Reverse < T > {
@@ -760,7 +775,7 @@ impl<T: Clone> Clone for Reverse<T> {
760
775
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
761
776
#[ rustc_diagnostic_item = "Ord" ]
762
777
#[ const_trait]
763
- pub trait Ord : Eq + PartialOrd < Self > {
778
+ pub trait Ord : ~ const Eq + ~ const PartialOrd < Self > {
764
779
/// This method returns an [`Ordering`] between `self` and `other`.
765
780
///
766
781
/// By convention, `self.cmp(&other)` returns the ordering matching the expression
@@ -1032,7 +1047,7 @@ pub macro Ord($item:item) {
1032
1047
) ]
1033
1048
#[ const_trait]
1034
1049
#[ rustc_diagnostic_item = "PartialOrd" ]
1035
- pub trait PartialOrd < Rhs : ?Sized = Self > : PartialEq < Rhs > {
1050
+ pub trait PartialOrd < Rhs : ?Sized = Self > : ~ const PartialEq < Rhs > {
1036
1051
/// This method returns an ordering between `self` and `other` values if one exists.
1037
1052
///
1038
1053
/// # Examples
@@ -1331,7 +1346,8 @@ mod impls {
1331
1346
macro_rules! eq_impl {
1332
1347
( $( $t: ty) * ) => ( $(
1333
1348
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1334
- impl Eq for $t { }
1349
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
1350
+ impl const Eq for $t { }
1335
1351
) * )
1336
1352
}
1337
1353
@@ -1455,7 +1471,8 @@ mod impls {
1455
1471
}
1456
1472
1457
1473
#[ unstable( feature = "never_type" , issue = "35121" ) ]
1458
- impl Eq for ! { }
1474
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
1475
+ impl const Eq for ! { }
1459
1476
1460
1477
#[ unstable( feature = "never_type" , issue = "35121" ) ]
1461
1478
#[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
@@ -1491,9 +1508,10 @@ mod impls {
1491
1508
}
1492
1509
}
1493
1510
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1494
- impl < A : ?Sized , B : ?Sized > PartialOrd < & B > for & A
1511
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
1512
+ impl < A : ?Sized , B : ?Sized > const PartialOrd < & B > for & A
1495
1513
where
1496
- A : PartialOrd < B > ,
1514
+ A : ~ const PartialOrd < B > ,
1497
1515
{
1498
1516
#[ inline]
1499
1517
fn partial_cmp ( & self , other : & & B ) -> Option < Ordering > {
@@ -1517,24 +1535,27 @@ mod impls {
1517
1535
}
1518
1536
}
1519
1537
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1520
- impl < A : ?Sized > Ord for & A
1538
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
1539
+ impl < A : ?Sized > const Ord for & A
1521
1540
where
1522
- A : Ord ,
1541
+ A : ~ const Ord ,
1523
1542
{
1524
1543
#[ inline]
1525
1544
fn cmp ( & self , other : & Self ) -> Ordering {
1526
1545
Ord :: cmp ( * self , * other)
1527
1546
}
1528
1547
}
1529
1548
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1530
- impl < A : ?Sized > Eq for & A where A : Eq { }
1549
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
1550
+ impl < A : ?Sized > const Eq for & A where A : ~const Eq { }
1531
1551
1532
1552
// &mut pointers
1533
1553
1534
1554
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1535
- impl < A : ?Sized , B : ?Sized > PartialEq < & mut B > for & mut A
1555
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
1556
+ impl < A : ?Sized , B : ?Sized > const PartialEq < & mut B > for & mut A
1536
1557
where
1537
- A : PartialEq < B > ,
1558
+ A : ~ const PartialEq < B > ,
1538
1559
{
1539
1560
#[ inline]
1540
1561
fn eq ( & self , other : & & mut B ) -> bool {
@@ -1546,9 +1567,10 @@ mod impls {
1546
1567
}
1547
1568
}
1548
1569
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1549
- impl < A : ?Sized , B : ?Sized > PartialOrd < & mut B > for & mut A
1570
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
1571
+ impl < A : ?Sized , B : ?Sized > const PartialOrd < & mut B > for & mut A
1550
1572
where
1551
- A : PartialOrd < B > ,
1573
+ A : ~ const PartialOrd < B > ,
1552
1574
{
1553
1575
#[ inline]
1554
1576
fn partial_cmp ( & self , other : & & mut B ) -> Option < Ordering > {
@@ -1572,22 +1594,25 @@ mod impls {
1572
1594
}
1573
1595
}
1574
1596
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1575
- impl < A : ?Sized > Ord for & mut A
1597
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
1598
+ impl < A : ?Sized > const Ord for & mut A
1576
1599
where
1577
- A : Ord ,
1600
+ A : ~ const Ord ,
1578
1601
{
1579
1602
#[ inline]
1580
1603
fn cmp ( & self , other : & Self ) -> Ordering {
1581
1604
Ord :: cmp ( * self , * other)
1582
1605
}
1583
1606
}
1584
1607
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1585
- impl < A : ?Sized > Eq for & mut A where A : Eq { }
1608
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
1609
+ impl < A : ?Sized > const Eq for & mut A where A : ~const Eq { }
1586
1610
1587
1611
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1588
- impl < A : ?Sized , B : ?Sized > PartialEq < & mut B > for & A
1612
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
1613
+ impl < A : ?Sized , B : ?Sized > const PartialEq < & mut B > for & A
1589
1614
where
1590
- A : PartialEq < B > ,
1615
+ A : ~ const PartialEq < B > ,
1591
1616
{
1592
1617
#[ inline]
1593
1618
fn eq ( & self , other : & & mut B ) -> bool {
@@ -1600,9 +1625,10 @@ mod impls {
1600
1625
}
1601
1626
1602
1627
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1603
- impl < A : ?Sized , B : ?Sized > PartialEq < & B > for & mut A
1628
+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
1629
+ impl < A : ?Sized , B : ?Sized > const PartialEq < & B > for & mut A
1604
1630
where
1605
- A : PartialEq < B > ,
1631
+ A : ~ const PartialEq < B > ,
1606
1632
{
1607
1633
#[ inline]
1608
1634
fn eq ( & self , other : & & B ) -> bool {
0 commit comments