@@ -546,7 +546,6 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
546
546
/// see `DefiningTy` for details.
547
547
fn defining_ty ( & self ) -> DefiningTy < ' tcx > {
548
548
let tcx = self . infcx . tcx ;
549
- let typeck_root_def_id = tcx. typeck_root_def_id ( self . mir_def . to_def_id ( ) ) ;
550
549
551
550
match tcx. hir ( ) . body_owner_kind ( self . mir_def ) {
552
551
BodyOwnerKind :: Closure | BodyOwnerKind :: Fn => {
@@ -574,35 +573,15 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
574
573
575
574
BodyOwnerKind :: Const | BodyOwnerKind :: Static ( ..) => {
576
575
match tcx. def_kind ( self . mir_def ) {
577
- DefKind :: InlineConst => {
578
- // FIXME this line creates a dependency between borrowck and typeck.
579
- //
580
- // This is required for `AscribeUserType` canonical query, which will call
581
- // `type_of(inline_const_def_id)`. That `type_of` would inject erased lifetimes
582
- // into borrowck, which is ICE #78174.
583
- //
584
- // As a workaround, inline consts have an additional generic param (`ty`
585
- // below), so that `type_of(inline_const_def_id).substs(substs)` uses the
586
- // proper type with NLL infer vars.
587
- let ty = tcx
588
- . typeck ( self . mir_def )
589
- . node_type ( tcx. local_def_id_to_hir_id ( self . mir_def ) ) ;
590
- let identity_substs =
591
- InternalSubsts :: identity_for_item ( tcx, typeck_root_def_id) ;
592
- let substs = InlineConstSubsts :: new (
593
- tcx,
594
- InlineConstSubstsParts { parent_substs : identity_substs, ty } ,
595
- )
596
- . substs ;
597
- let substs =
598
- self . infcx . replace_free_regions_with_nll_infer_vars ( FR , substs) ;
599
- DefiningTy :: InlineConst ( self . mir_def . to_def_id ( ) , substs)
600
- }
601
- DefKind :: Promoted => {
602
- let body = tcx. mir_for_promoted ( self . mir_def ) . borrow ( ) ;
576
+ DefKind :: InlineConst | DefKind :: Promoted => {
577
+ // Fetch the actual type from MIR, as `type_of` returns something useless
578
+ // like `<const_ty>`.
579
+ let body = tcx. mir_promoted ( self . mir_def ) . 0 . borrow ( ) ;
603
580
let ty = body. local_decls [ RETURN_PLACE ] . ty ;
604
- let parent_def_id = tcx. parent ( self . mir_def . to_def_id ( ) ) ;
605
- let parent_substs = InternalSubsts :: identity_for_item ( tcx, parent_def_id) ;
581
+
582
+ let typeck_root_def_id = tcx. typeck_root_def_id ( self . mir_def . to_def_id ( ) ) ;
583
+ let parent_substs =
584
+ InternalSubsts :: identity_for_item ( tcx, typeck_root_def_id) ;
606
585
let substs = InlineConstSubsts :: new (
607
586
tcx,
608
587
InlineConstSubstsParts { parent_substs, ty } ,
0 commit comments