@@ -204,14 +204,17 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
204
204
205
205
let success = Cell :: new ( true ) ;
206
206
let err_pred = AutoTrait ( DefId :: local ( CRATE_DEF_INDEX ) ) ;
207
+ // A `Self` within original bounds are to be substituted
208
+ // with a `trait_object_dummy_self`.
209
+ let dummy_self = self . tcx . types . trait_object_dummy_self ;
207
210
208
211
let res: Vec < _ > = preds
209
212
. iter ( )
210
213
. map ( |p| {
211
214
match * p. skip_binder ( ) {
212
215
Trait ( existential_trait_ref) => {
213
216
let trait_ref = Binder :: bind ( existential_trait_ref)
214
- . with_self_ty ( self . tcx , self . tcx . types . err ) ;
217
+ . with_self_ty ( self . tcx , dummy_self ) ;
215
218
let did = trait_ref. skip_binder ( ) . def_id ;
216
219
let substs = trait_ref. skip_binder ( ) . substs ;
217
220
@@ -234,7 +237,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
234
237
}
235
238
Projection ( existential_projection) => {
236
239
let projection_pred = Binder :: bind ( existential_projection)
237
- . with_self_ty ( self . tcx , self . tcx . types . err ) ;
240
+ . with_self_ty ( self . tcx , dummy_self ) ;
238
241
let item_def_id =
239
242
projection_pred. skip_binder ( ) . projection_ty . item_def_id ;
240
243
let substs =
@@ -561,7 +564,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for InferenceCleanupFolder<'a, 'tcx> {
561
564
. tcx
562
565
. mk_ref ( self . infcx . tcx . lifetimes . re_erased , ty_and_mut)
563
566
}
564
- TyKind :: Infer ( _) => self . infcx . tcx . mk_ty ( TyKind :: Error ) ,
567
+ TyKind :: Infer ( _) => self . infcx . tcx . ty_error ( ) ,
565
568
_ => t1,
566
569
}
567
570
}
0 commit comments