@@ -1016,14 +1016,23 @@ impl<'tcx> GenericPredicates<'tcx> {
1016
1016
}
1017
1017
}
1018
1018
1019
- #[ derive( Clone , Copy , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable , Lift ) ]
1019
+ #[ derive( Clone , Copy , Hash , RustcEncodable , RustcDecodable , Lift ) ]
1020
1020
#[ derive( HashStable ) ]
1021
1021
pub struct Predicate < ' tcx > {
1022
1022
kind : & ' tcx PredicateKind < ' tcx > ,
1023
1023
}
1024
1024
1025
- impl Predicate < ' tcx > {
1026
- pub fn kind ( & self ) -> & ' tcx PredicateKind < ' tcx > {
1025
+ impl < ' tcx > PartialEq for Predicate < ' tcx > {
1026
+ fn eq ( & self , other : & Self ) -> bool {
1027
+ // `self.kind` is always interned.
1028
+ ptr:: eq ( self . kind , other. kind )
1029
+ }
1030
+ }
1031
+
1032
+ impl < ' tcx > Eq for Predicate < ' tcx > { }
1033
+
1034
+ impl < ' tcx > Predicate < ' tcx > {
1035
+ pub fn kind ( self ) -> & ' tcx PredicateKind < ' tcx > {
1027
1036
self . kind
1028
1037
}
1029
1038
}
@@ -1098,7 +1107,7 @@ impl<'tcx> Predicate<'tcx> {
1098
1107
/// substitution in terms of what happens with bound regions. See
1099
1108
/// lengthy comment below for details.
1100
1109
pub fn subst_supertrait (
1101
- & self ,
1110
+ self ,
1102
1111
tcx : TyCtxt < ' tcx > ,
1103
1112
trait_ref : & ty:: PolyTraitRef < ' tcx > ,
1104
1113
) -> ty:: Predicate < ' tcx > {
@@ -1369,7 +1378,7 @@ impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
1369
1378
}
1370
1379
1371
1380
impl < ' tcx > Predicate < ' tcx > {
1372
- pub fn to_opt_poly_trait_ref ( & self ) -> Option < PolyTraitRef < ' tcx > > {
1381
+ pub fn to_opt_poly_trait_ref ( self ) -> Option < PolyTraitRef < ' tcx > > {
1373
1382
match self . kind ( ) {
1374
1383
& PredicateKind :: Trait ( ref t, _) => Some ( t. to_poly_trait_ref ( ) ) ,
1375
1384
PredicateKind :: Projection ( ..)
@@ -1384,7 +1393,7 @@ impl<'tcx> Predicate<'tcx> {
1384
1393
}
1385
1394
}
1386
1395
1387
- pub fn to_opt_type_outlives ( & self ) -> Option < PolyTypeOutlivesPredicate < ' tcx > > {
1396
+ pub fn to_opt_type_outlives ( self ) -> Option < PolyTypeOutlivesPredicate < ' tcx > > {
1388
1397
match self . kind ( ) {
1389
1398
& PredicateKind :: TypeOutlives ( data) => Some ( data) ,
1390
1399
PredicateKind :: Trait ( ..)
0 commit comments