@@ -752,6 +752,10 @@ impl<'tcx> TraitPredicate<'tcx> {
752
752
pub fn self_ty ( self ) -> Ty < ' tcx > {
753
753
self . trait_ref . self_ty ( )
754
754
}
755
+
756
+ pub fn substs ( self ) -> SubstsRef < ' tcx > {
757
+ self . trait_ref . substs
758
+ }
755
759
}
756
760
757
761
impl < ' tcx > PolyTraitPredicate < ' tcx > {
@@ -763,6 +767,10 @@ impl<'tcx> PolyTraitPredicate<'tcx> {
763
767
pub fn self_ty ( self ) -> ty:: Binder < ' tcx , Ty < ' tcx > > {
764
768
self . map_bound ( |trait_ref| trait_ref. self_ty ( ) )
765
769
}
770
+
771
+ pub fn substs ( self ) -> ty:: Binder < ' tcx , SubstsRef < ' tcx > > {
772
+ self . map_bound ( |trait_ref| trait_ref. substs ( ) )
773
+ }
766
774
}
767
775
768
776
#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , Debug , TyEncodable , TyDecodable ) ]
@@ -1588,6 +1596,40 @@ impl VariantDef {
1588
1596
}
1589
1597
}
1590
1598
1599
+ impl PartialOrd for VariantDef {
1600
+ fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
1601
+ Some ( self . cmp ( & other) )
1602
+ }
1603
+ }
1604
+
1605
+ /// There should be only one VariantDef for each `def_id`, therefore
1606
+ /// it is fine to implement `Ord` only based on `def_id`.
1607
+ impl Ord for VariantDef {
1608
+ fn cmp ( & self , other : & Self ) -> Ordering {
1609
+ self . def_id . cmp ( & other. def_id )
1610
+ }
1611
+ }
1612
+
1613
+ /// There should be only one VariantDef for each `def_id`, therefore
1614
+ /// it is fine to implement `PartialEq` only based on `def_id`.
1615
+ impl PartialEq for VariantDef {
1616
+ #[ inline]
1617
+ fn eq ( & self , other : & Self ) -> bool {
1618
+ self . def_id == other. def_id
1619
+ }
1620
+ }
1621
+
1622
+ impl Eq for VariantDef { }
1623
+
1624
+ /// There should be only one VariantDef for each `def_id`, therefore
1625
+ /// it is fine to implement `Hash` only based on `def_id`.
1626
+ impl Hash for VariantDef {
1627
+ #[ inline]
1628
+ fn hash < H : Hasher > ( & self , s : & mut H ) {
1629
+ self . def_id . hash ( s)
1630
+ }
1631
+ }
1632
+
1591
1633
#[ derive( Copy , Clone , Debug , PartialEq , Eq , TyEncodable , TyDecodable , HashStable ) ]
1592
1634
pub enum VariantDiscr {
1593
1635
/// Explicit value for this variant, i.e., `X = 123`.
@@ -1608,6 +1650,40 @@ pub struct FieldDef {
1608
1650
pub vis : Visibility ,
1609
1651
}
1610
1652
1653
+ impl PartialOrd for FieldDef {
1654
+ fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
1655
+ Some ( self . cmp ( & other) )
1656
+ }
1657
+ }
1658
+
1659
+ /// There should be only one FieldDef for each `did`, therefore
1660
+ /// it is fine to implement `Ord` only based on `did`.
1661
+ impl Ord for FieldDef {
1662
+ fn cmp ( & self , other : & Self ) -> Ordering {
1663
+ self . did . cmp ( & other. did )
1664
+ }
1665
+ }
1666
+
1667
+ /// There should be only one FieldDef for each `did`, therefore
1668
+ /// it is fine to implement `PartialEq` only based on `did`.
1669
+ impl PartialEq for FieldDef {
1670
+ #[ inline]
1671
+ fn eq ( & self , other : & Self ) -> bool {
1672
+ self . did == other. did
1673
+ }
1674
+ }
1675
+
1676
+ impl Eq for FieldDef { }
1677
+
1678
+ /// There should be only one FieldDef for each `did`, therefore
1679
+ /// it is fine to implement `Hash` only based on `did`.
1680
+ impl Hash for FieldDef {
1681
+ #[ inline]
1682
+ fn hash < H : Hasher > ( & self , s : & mut H ) {
1683
+ self . did . hash ( s)
1684
+ }
1685
+ }
1686
+
1611
1687
bitflags ! {
1612
1688
#[ derive( TyEncodable , TyDecodable , Default , HashStable ) ]
1613
1689
pub struct ReprFlags : u8 {
0 commit comments