@@ -1030,7 +1030,7 @@ impl<'tcx> GenericPredicates<'tcx> {
1030
1030
1031
1031
#[ derive( Debug ) ]
1032
1032
crate struct PredicateInner < ' tcx > {
1033
- binder : Binder < PredicateKind < ' tcx > > ,
1033
+ kind : Binder < PredicateKind < ' tcx > > ,
1034
1034
flags : TypeFlags ,
1035
1035
/// See the comment for the corresponding field of [TyS].
1036
1036
outer_exclusive_binder : ty:: DebruijnIndex ,
@@ -1060,29 +1060,29 @@ impl Hash for Predicate<'_> {
1060
1060
impl < ' tcx > Eq for Predicate < ' tcx > { }
1061
1061
1062
1062
impl < ' tcx > Predicate < ' tcx > {
1063
- /// Converts this to a `Binder<PredicateKind<'tcx>>`. If the value was an
1064
- /// `Atom`, then it is not allowed to contain escaping bound vars.
1063
+ /// Gets the inner `Binder<PredicateKind<'tcx>>`.
1065
1064
pub fn kind ( self ) -> Binder < PredicateKind < ' tcx > > {
1066
- self . inner . binder
1065
+ self . inner . kind
1067
1066
}
1068
1067
1069
- pub fn kind_ref ( self ) -> & ' tcx Binder < PredicateKind < ' tcx > > {
1070
- & self . inner . binder
1068
+ /// Like `kind` but returns a reference. Only needed because of encoding.
1069
+ pub ( super ) fn kind_ref ( self ) -> & ' tcx Binder < PredicateKind < ' tcx > > {
1070
+ & self . inner . kind
1071
1071
}
1072
1072
}
1073
1073
1074
1074
impl < ' a , ' tcx > HashStable < StableHashingContext < ' a > > for Predicate < ' tcx > {
1075
1075
fn hash_stable ( & self , hcx : & mut StableHashingContext < ' a > , hasher : & mut StableHasher ) {
1076
1076
let PredicateInner {
1077
- ref binder ,
1077
+ ref kind ,
1078
1078
1079
1079
// The other fields just provide fast access to information that is
1080
1080
// also contained in `kind`, so no need to hash them.
1081
1081
flags : _,
1082
1082
outer_exclusive_binder : _,
1083
1083
} = self . inner ;
1084
1084
1085
- binder . hash_stable ( hcx, hasher) ;
1085
+ kind . hash_stable ( hcx, hasher) ;
1086
1086
}
1087
1087
}
1088
1088
@@ -1221,7 +1221,7 @@ impl<'tcx> Predicate<'tcx> {
1221
1221
let substs = trait_ref. skip_binder ( ) . substs ;
1222
1222
let pred = self . kind ( ) . skip_binder ( ) ;
1223
1223
let new = pred. subst ( tcx, substs) ;
1224
- if new != pred { ty:: Binder :: bind ( new) . to_predicate ( tcx ) } else { self }
1224
+ tcx . reuse_or_mk_predicate ( self , ty:: Binder :: bind ( new) )
1225
1225
}
1226
1226
}
1227
1227
@@ -1352,7 +1352,6 @@ impl ToPredicate<'tcx> for Binder<PredicateKind<'tcx>> {
1352
1352
impl ToPredicate < ' tcx > for PredicateKind < ' tcx > {
1353
1353
#[ inline( always) ]
1354
1354
fn to_predicate ( self , tcx : TyCtxt < ' tcx > ) -> Predicate < ' tcx > {
1355
- debug_assert ! ( !self . has_escaping_bound_vars( ) , "escaping bound vars for {:?}" , self ) ;
1356
1355
tcx. mk_predicate ( Binder :: dummy ( self ) )
1357
1356
}
1358
1357
}
0 commit comments