@@ -211,61 +211,72 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
211
211
let res: Vec < _ > = preds
212
212
. iter ( )
213
213
. map ( |p| {
214
- match p. skip_binder ( ) {
215
- Trait ( existential_trait_ref) => {
216
- let trait_ref = Binder :: bind ( existential_trait_ref)
217
- . with_self_ty ( self . tcx , dummy_self) ;
218
- let did = trait_ref. skip_binder ( ) . def_id ;
219
- let substs = trait_ref. skip_binder ( ) . substs ;
220
-
221
- // TODO: here, the substs could also be already translated
222
- if let Some ( ( target_def_id, target_substs) ) =
223
- self . translate_orig_substs ( index_map, did, substs)
224
- {
225
- let target_trait_ref = TraitRef {
226
- def_id : target_def_id,
227
- substs : target_substs,
228
- } ;
229
- Trait ( ExistentialTraitRef :: erase_self_ty (
230
- self . tcx ,
231
- target_trait_ref,
232
- ) )
233
- } else {
234
- success. set ( false ) ;
235
- err_pred
214
+ p. map_bound ( |p| {
215
+ match p {
216
+ Trait ( existential_trait_ref) => {
217
+ let trait_ref = Binder :: bind ( existential_trait_ref)
218
+ . with_self_ty ( self . tcx , dummy_self) ;
219
+ let did = trait_ref. skip_binder ( ) . def_id ;
220
+ let substs = trait_ref. skip_binder ( ) . substs ;
221
+
222
+ // TODO: here, the substs could also be already translated
223
+ if let Some ( ( target_def_id, target_substs) ) =
224
+ self . translate_orig_substs ( index_map, did, substs)
225
+ {
226
+ let target_trait_ref = TraitRef {
227
+ def_id : target_def_id,
228
+ substs : target_substs,
229
+ } ;
230
+ Trait ( ExistentialTraitRef :: erase_self_ty (
231
+ self . tcx ,
232
+ target_trait_ref,
233
+ ) )
234
+ } else {
235
+ success. set ( false ) ;
236
+ err_pred
237
+ }
236
238
}
237
- }
238
- Projection ( existential_projection) => {
239
- let projection_pred = Binder :: bind ( existential_projection)
240
- . with_self_ty ( self . tcx , dummy_self) ;
241
- let item_def_id =
242
- projection_pred. skip_binder ( ) . projection_ty . item_def_id ;
243
- let substs =
244
- projection_pred. skip_binder ( ) . projection_ty . substs ;
245
-
246
- // TODO: here, the substs could also be already translated
247
- if let Some ( ( target_def_id, target_substs) ) = self
248
- . translate_orig_substs ( index_map, item_def_id, substs)
249
- {
250
- Projection ( ExistentialProjection {
251
- item_def_id : target_def_id,
252
- // TODO: should be it's own method in rustc
253
- substs : self . tcx . intern_substs ( & target_substs[ 1 ..] ) ,
254
- ty,
255
- } )
256
- } else {
257
- success. set ( false ) ;
258
- err_pred
239
+ Projection ( existential_projection) => {
240
+ let projection_pred =
241
+ Binder :: bind ( existential_projection)
242
+ . with_self_ty ( self . tcx , dummy_self) ;
243
+ let item_def_id = projection_pred
244
+ . skip_binder ( )
245
+ . projection_ty
246
+ . item_def_id ;
247
+ let substs =
248
+ projection_pred. skip_binder ( ) . projection_ty . substs ;
249
+
250
+ // TODO: here, the substs could also be already translated
251
+ if let Some ( ( target_def_id, target_substs) ) = self
252
+ . translate_orig_substs (
253
+ index_map,
254
+ item_def_id,
255
+ substs,
256
+ )
257
+ {
258
+ Projection ( ExistentialProjection {
259
+ item_def_id : target_def_id,
260
+ // TODO: should be it's own method in rustc
261
+ substs : self
262
+ . tcx
263
+ . intern_substs ( & target_substs[ 1 ..] ) ,
264
+ ty,
265
+ } )
266
+ } else {
267
+ success. set ( false ) ;
268
+ err_pred
269
+ }
259
270
}
271
+ AutoTrait ( did) => AutoTrait ( self . translate_orig ( did) ) ,
260
272
}
261
- AutoTrait ( did) => AutoTrait ( self . translate_orig ( did) ) ,
262
- }
273
+ } )
263
274
} )
264
275
. collect ( ) ;
265
276
266
277
if success. get ( ) {
267
- let target_preds = self . tcx . mk_existential_predicates ( res. iter ( ) ) ;
268
- self . tcx . mk_dynamic ( Binder :: bind ( target_preds) , region)
278
+ let target_preds = self . tcx . mk_poly_existential_predicates ( res. iter ( ) ) ;
279
+ self . tcx . mk_dynamic ( target_preds, region)
269
280
} else {
270
281
ty
271
282
}
@@ -365,12 +376,12 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
365
376
predicate : Predicate < ' tcx > ,
366
377
) -> Option < Predicate < ' tcx > > {
367
378
use rustc_middle:: ty:: {
368
- OutlivesPredicate , PredicateAtom , PredicateKind , ProjectionPredicate , ProjectionTy ,
369
- SubtypePredicate , ToPredicate , TraitPredicate , WithOptConstParam ,
379
+ Binder , OutlivesPredicate , PredicateAtom , PredicateKind , ProjectionPredicate ,
380
+ ProjectionTy , SubtypePredicate , ToPredicate , TraitPredicate , WithOptConstParam ,
370
381
} ;
371
382
372
383
Some ( match predicate. skip_binders ( ) {
373
- PredicateAtom :: Trait ( pred, constness) => PredicateAtom :: Trait (
384
+ PredicateAtom :: Trait ( pred, constness) => Binder :: bind ( PredicateAtom :: Trait (
374
385
if let Some ( ( target_def_id, target_substs) ) = self . translate_orig_substs (
375
386
index_map,
376
387
pred. trait_ref . def_id ,
@@ -386,21 +397,21 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
386
397
return None ;
387
398
} ,
388
399
constness,
389
- )
400
+ ) )
390
401
. potentially_quantified ( self . tcx , PredicateKind :: ForAll ) ,
391
- PredicateAtom :: RegionOutlives ( pred) => PredicateAtom :: RegionOutlives ( {
402
+ PredicateAtom :: RegionOutlives ( pred) => Binder :: bind ( PredicateAtom :: RegionOutlives ( {
392
403
let l = self . translate_region ( pred. 0 ) ;
393
404
let r = self . translate_region ( pred. 1 ) ;
394
405
OutlivesPredicate ( l, r)
395
- } )
406
+ } ) )
396
407
. potentially_quantified ( self . tcx , PredicateKind :: ForAll ) ,
397
- PredicateAtom :: TypeOutlives ( pred) => PredicateAtom :: TypeOutlives ( {
408
+ PredicateAtom :: TypeOutlives ( pred) => Binder :: bind ( PredicateAtom :: TypeOutlives ( {
398
409
let l = self . translate ( index_map, pred. 0 ) ;
399
410
let r = self . translate_region ( pred. 1 ) ;
400
411
OutlivesPredicate ( l, r)
401
- } )
412
+ } ) )
402
413
. potentially_quantified ( self . tcx , PredicateKind :: ForAll ) ,
403
- PredicateAtom :: Projection ( pred) => PredicateAtom :: Projection (
414
+ PredicateAtom :: Projection ( pred) => Binder :: bind ( PredicateAtom :: Projection (
404
415
if let Some ( ( target_def_id, target_substs) ) = self . translate_orig_substs (
405
416
index_map,
406
417
pred. projection_ty . item_def_id ,
@@ -416,7 +427,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
416
427
} else {
417
428
return None ;
418
429
} ,
419
- )
430
+ ) )
420
431
. potentially_quantified ( self . tcx , PredicateKind :: ForAll ) ,
421
432
PredicateAtom :: WellFormed ( ty) => {
422
433
PredicateAtom :: WellFormed ( self . translate ( index_map, ty) ) . to_predicate ( self . tcx )
0 commit comments