@@ -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
}
0 commit comments