@@ -5330,7 +5330,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5330
5330
}
5331
5331
5332
5332
// Rewrite `SelfCtor` to `Ctor`
5333
- pub fn rewrite_self_ctor ( & self , def : Def , span : Span ) -> ( Def , DefId , Ty < ' tcx > ) {
5333
+ pub fn rewrite_self_ctor ( & self , def : Def , span : Span ) -> Def {
5334
5334
let tcx = self . tcx ;
5335
5335
if let Def :: SelfCtor ( impl_def_id) = def {
5336
5336
let ty = self . impl_self_ty ( span, impl_def_id) . ty ;
@@ -5340,8 +5340,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5340
5340
Some ( adt_def) if adt_def. has_ctor ( ) => {
5341
5341
let variant = adt_def. non_enum_variant ( ) ;
5342
5342
let ctor_def_id = variant. ctor_def_id . unwrap ( ) ;
5343
- let def = Def :: Ctor ( ctor_def_id, CtorOf :: Struct , variant. ctor_kind ) ;
5344
- ( def, ctor_def_id, tcx. type_of ( ctor_def_id) )
5343
+ Def :: Ctor ( ctor_def_id, CtorOf :: Struct , variant. ctor_kind )
5345
5344
}
5346
5345
_ => {
5347
5346
let mut err = tcx. sess . struct_span_err ( span,
@@ -5364,16 +5363,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5364
5363
}
5365
5364
err. emit ( ) ;
5366
5365
5367
- ( def, impl_def_id , tcx . types . err )
5366
+ def
5368
5367
}
5369
5368
}
5370
5369
} else {
5371
- let def_id = def. def_id ( ) ;
5372
-
5373
- // The things we are substituting into the type should not contain
5374
- // escaping late-bound regions, and nor should the base type scheme.
5375
- let ty = tcx. type_of ( def_id) ;
5376
- ( def, def_id, ty)
5370
+ def
5377
5371
}
5378
5372
}
5379
5373
@@ -5396,7 +5390,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5396
5390
5397
5391
let tcx = self . tcx ;
5398
5392
5399
- let ( def, def_id , ty ) = self . rewrite_self_ctor ( def, span) ;
5393
+ let def = self . rewrite_self_ctor ( def, span) ;
5400
5394
let path_segs = AstConv :: def_ids_for_path_segments ( self , segments, self_ty, def) ;
5401
5395
5402
5396
let mut user_self_ty = None ;
@@ -5501,6 +5495,20 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5501
5495
tcx. generics_of ( * def_id) . has_self
5502
5496
} ) . unwrap_or ( false ) ;
5503
5497
5498
+ let ( def_id, ty) = if let Def :: SelfCtor ( impl_def_id) = def {
5499
+ // NOTE(eddyb) an error has already been emitted by `rewrite_self_ctor`,
5500
+ // avoid using the wrong type here. This isn't in `rewrite_self_ctor`
5501
+ // itself because that runs too early (see #60989).
5502
+ ( impl_def_id, tcx. types . err )
5503
+ } else {
5504
+ let def_id = def. def_id ( ) ;
5505
+
5506
+ // The things we are substituting into the type should not contain
5507
+ // escaping late-bound regions, and nor should the base type scheme.
5508
+ let ty = tcx. type_of ( def_id) ;
5509
+ ( def_id, ty)
5510
+ } ;
5511
+
5504
5512
let substs = AstConv :: create_substs_for_generic_args (
5505
5513
tcx,
5506
5514
def_id,
0 commit comments