@@ -752,6 +752,10 @@ impl<'tcx> TraitPredicate<'tcx> {
752752 pub fn self_ty ( self ) -> Ty < ' tcx > {
753753 self . trait_ref . self_ty ( )
754754 }
755+
756+ pub fn substs ( self ) -> SubstsRef < ' tcx > {
757+ self . trait_ref . substs
758+ }
755759}
756760
757761impl < ' tcx > PolyTraitPredicate < ' tcx > {
@@ -763,6 +767,10 @@ impl<'tcx> PolyTraitPredicate<'tcx> {
763767 pub fn self_ty ( self ) -> ty:: Binder < ' tcx , Ty < ' tcx > > {
764768 self . map_bound ( |trait_ref| trait_ref. self_ty ( ) )
765769 }
770+
771+ pub fn substs ( self ) -> ty:: Binder < ' tcx , SubstsRef < ' tcx > > {
772+ self . map_bound ( |trait_ref| trait_ref. substs ( ) )
773+ }
766774}
767775
768776#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , Debug , TyEncodable , TyDecodable ) ]
@@ -1588,6 +1596,40 @@ impl VariantDef {
15881596 }
15891597}
15901598
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+
15911633#[ derive( Copy , Clone , Debug , PartialEq , Eq , TyEncodable , TyDecodable , HashStable ) ]
15921634pub enum VariantDiscr {
15931635 /// Explicit value for this variant, i.e., `X = 123`.
@@ -1608,6 +1650,40 @@ pub struct FieldDef {
16081650 pub vis : Visibility ,
16091651}
16101652
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+
16111687bitflags ! {
16121688 #[ derive( TyEncodable , TyDecodable , Default , HashStable ) ]
16131689 pub struct ReprFlags : u8 {
0 commit comments