@@ -16,7 +16,8 @@ use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCoercion};
16
16
use rustc_middle:: ty:: adjustment:: { AllowTwoPhase , AutoBorrow , AutoBorrowMutability } ;
17
17
use rustc_middle:: ty:: fold:: TypeFoldable ;
18
18
use rustc_middle:: ty:: {
19
- self , GenericArgs , GenericArgsRef , GenericParamDefKind , Ty , TyCtxt , UserArgs , UserType ,
19
+ self , GenericArgs , GenericArgsRef , GenericParamDefKind , Ty , TyCtxt , TypeVisitableExt , UserArgs ,
20
+ UserType ,
20
21
} ;
21
22
use rustc_middle:: { bug, span_bug} ;
22
23
use rustc_span:: { Span , DUMMY_SP } ;
@@ -268,6 +269,17 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
268
269
269
270
probe:: ObjectPick => {
270
271
let trait_def_id = pick. item . container_id ( self . tcx ) ;
272
+
273
+ // This shouldn't happen for non-region error kinds, but may occur
274
+ // when we have error regions. Specifically, since we canonicalize
275
+ // during method steps, we may successfully deref when we assemble
276
+ // the pick, but fail to deref when we try to extract the object
277
+ // type from the pick during confirmation. This is fine, we're basically
278
+ // already doomed by this point.
279
+ if self_ty. references_error ( ) {
280
+ return ty:: GenericArgs :: extend_with_error ( self . tcx , trait_def_id, & [ ] ) ;
281
+ }
282
+
271
283
self . extract_existential_trait_ref ( self_ty, |this, object_ty, principal| {
272
284
// The object data has no entry for the Self
273
285
// Type. For the purposes of this method call, we
0 commit comments