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