@@ -1303,37 +1303,20 @@ impl<'tcx> Predicate<'tcx> {
1303
1303
// this trick achieves that).
1304
1304
1305
1305
let substs = trait_ref. skip_binder ( ) . substs ;
1306
- let kind = self . kind ( ) ;
1307
- let new = match kind {
1308
- & PredicateKind :: Trait ( ref binder, constness) => {
1309
- PredicateKind :: Trait ( binder. map_bound ( |data| data. subst ( tcx, substs) ) , constness)
1310
- }
1311
- PredicateKind :: Subtype ( binder) => {
1312
- PredicateKind :: Subtype ( binder. map_bound ( |data| data. subst ( tcx, substs) ) )
1313
- }
1314
- PredicateKind :: RegionOutlives ( binder) => {
1315
- PredicateKind :: RegionOutlives ( binder. map_bound ( |data| data. subst ( tcx, substs) ) )
1316
- }
1317
- PredicateKind :: TypeOutlives ( binder) => {
1318
- PredicateKind :: TypeOutlives ( binder. map_bound ( |data| data. subst ( tcx, substs) ) )
1319
- }
1320
- PredicateKind :: Projection ( binder) => {
1321
- PredicateKind :: Projection ( binder. map_bound ( |data| data. subst ( tcx, substs) ) )
1322
- }
1323
- & PredicateKind :: WellFormed ( data) => PredicateKind :: WellFormed ( data. subst ( tcx, substs) ) ,
1324
- & PredicateKind :: ObjectSafe ( trait_def_id) => PredicateKind :: ObjectSafe ( trait_def_id) ,
1325
- & PredicateKind :: ClosureKind ( closure_def_id, closure_substs, kind) => {
1326
- PredicateKind :: ClosureKind ( closure_def_id, closure_substs. subst ( tcx, substs) , kind)
1327
- }
1328
- & PredicateKind :: ConstEvaluatable ( def_id, const_substs) => {
1329
- PredicateKind :: ConstEvaluatable ( def_id, const_substs. subst ( tcx, substs) )
1330
- }
1331
- PredicateKind :: ConstEquate ( c1, c2) => {
1332
- PredicateKind :: ConstEquate ( c1. subst ( tcx, substs) , c2. subst ( tcx, substs) )
1333
- }
1306
+ let kind = match self . kint ( tcx) {
1307
+ PredicateKint :: ForAll ( binder) => * binder. skip_binder ( ) ,
1308
+ kind => kind,
1309
+ } ;
1310
+
1311
+ let new = kind. subst ( tcx, substs) ;
1312
+
1313
+ let rebound = if new. has_escaping_bound_vars ( ) {
1314
+ PredicateKint :: ForAll ( Binder :: bind ( tcx. intern_predicate_kint ( new) ) )
1315
+ } else {
1316
+ new
1334
1317
} ;
1335
1318
1336
- if new != * kind { new . to_predicate ( tcx) } else { self }
1319
+ if rebound != * kind { rebound . to_predicate ( tcx) } else { self }
1337
1320
}
1338
1321
}
1339
1322
0 commit comments