@@ -430,6 +430,7 @@ fn mir_promoted(
430430 def : LocalDefId ,
431431) -> ( & Steal < Body < ' _ > > , & Steal < IndexVec < Promoted , Body < ' _ > > > ) {
432432 debug_assert ! ( !tcx. is_trivial_const( def) , "Tried to get mir_promoted of a trivial const" ) ;
433+ debug_assert ! ( !tcx. is_constructor( def. to_def_id( ) ) ) ;
433434
434435 // Ensure that we compute the `mir_const_qualif` for constants at
435436 // this point, before we steal the mir-const result.
@@ -492,7 +493,6 @@ fn mir_for_ctfe(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &Body<'_> {
492493}
493494
494495fn inner_mir_for_ctfe ( tcx : TyCtxt < ' _ > , def : LocalDefId ) -> Body < ' _ > {
495- // FIXME: don't duplicate this between the optimized_mir/mir_for_ctfe queries
496496 if tcx. is_constructor ( def. to_def_id ( ) ) {
497497 // There's no reason to run all of the MIR passes on constructors when
498498 // we can just output the MIR we want directly. This also saves const
@@ -785,18 +785,18 @@ pub(crate) fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'
785785
786786/// Optimize the MIR and prepare it for codegen.
787787fn optimized_mir ( tcx : TyCtxt < ' _ > , did : LocalDefId ) -> & Body < ' _ > {
788- tcx. arena . alloc ( inner_optimized_mir ( tcx, did) )
789- }
790-
791- fn inner_optimized_mir ( tcx : TyCtxt < ' _ > , did : LocalDefId ) -> Body < ' _ > {
792788 if tcx. is_constructor ( did. to_def_id ( ) ) {
793789 // There's no reason to run all of the MIR passes on constructors when
794790 // we can just output the MIR we want directly. This also saves const
795791 // qualification and borrow checking the trouble of special casing
796792 // constructors.
797- return shim :: build_adt_ctor ( tcx, did . to_def_id ( ) ) ;
793+ return tcx. mir_for_ctfe ( did ) ;
798794 }
799795
796+ tcx. arena . alloc ( inner_optimized_mir ( tcx, did) )
797+ }
798+
799+ fn inner_optimized_mir ( tcx : TyCtxt < ' _ > , did : LocalDefId ) -> Body < ' _ > {
800800 match tcx. hir_body_const_context ( did) {
801801 // Run the `mir_for_ctfe` query, which depends on `mir_drops_elaborated_and_const_checked`
802802 // which we are going to steal below. Thus we need to run `mir_for_ctfe` first, so it
0 commit comments