@@ -1030,7 +1030,7 @@ impl<'tcx> GenericPredicates<'tcx> {
10301030
10311031#[ derive( Debug ) ]
10321032crate struct PredicateInner < ' tcx > {
1033- binder : Binder < PredicateKind < ' tcx > > ,
1033+ kind : Binder < PredicateKind < ' tcx > > ,
10341034 flags : TypeFlags ,
10351035 /// See the comment for the corresponding field of [TyS].
10361036 outer_exclusive_binder : ty:: DebruijnIndex ,
@@ -1060,29 +1060,29 @@ impl Hash for Predicate<'_> {
10601060impl < ' tcx > Eq for Predicate < ' tcx > { }
10611061
10621062impl < ' 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>>`.
10651064 pub fn kind ( self ) -> Binder < PredicateKind < ' tcx > > {
1066- self . inner . binder
1065+ self . inner . kind
10671066 }
10681067
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
10711071 }
10721072}
10731073
10741074impl < ' a , ' tcx > HashStable < StableHashingContext < ' a > > for Predicate < ' tcx > {
10751075 fn hash_stable ( & self , hcx : & mut StableHashingContext < ' a > , hasher : & mut StableHasher ) {
10761076 let PredicateInner {
1077- ref binder ,
1077+ ref kind ,
10781078
10791079 // The other fields just provide fast access to information that is
10801080 // also contained in `kind`, so no need to hash them.
10811081 flags : _,
10821082 outer_exclusive_binder : _,
10831083 } = self . inner ;
10841084
1085- binder . hash_stable ( hcx, hasher) ;
1085+ kind . hash_stable ( hcx, hasher) ;
10861086 }
10871087}
10881088
@@ -1221,7 +1221,7 @@ impl<'tcx> Predicate<'tcx> {
12211221 let substs = trait_ref. skip_binder ( ) . substs ;
12221222 let pred = self . kind ( ) . skip_binder ( ) ;
12231223 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) )
12251225 }
12261226}
12271227
@@ -1352,7 +1352,6 @@ impl ToPredicate<'tcx> for Binder<PredicateKind<'tcx>> {
13521352impl ToPredicate < ' tcx > for PredicateKind < ' tcx > {
13531353 #[ inline( always) ]
13541354 fn to_predicate ( self , tcx : TyCtxt < ' tcx > ) -> Predicate < ' tcx > {
1355- debug_assert ! ( !self . has_escaping_bound_vars( ) , "escaping bound vars for {:?}" , self ) ;
13561355 tcx. mk_predicate ( Binder :: dummy ( self ) )
13571356 }
13581357}
0 commit comments