@@ -387,7 +387,9 @@ fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -
387
387
. body_const_context ( def. did )
388
388
. expect ( "mir_for_ctfe should not be used for runtime functions" ) ;
389
389
390
- let mut body = tcx. mir_drops_elaborated_and_const_checked ( def) . borrow ( ) . clone ( ) ;
390
+ let body = tcx. mir_drops_elaborated_and_const_checked ( def) . borrow ( ) . clone ( ) ;
391
+
392
+ let mut body = remap_mir_for_const_eval_select ( tcx, body, hir:: Constness :: Const ) ;
391
393
392
394
match context {
393
395
// Do not const prop functions, either they get executed at runtime or exported to metadata,
@@ -416,7 +418,7 @@ fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -
416
418
417
419
debug_assert ! ( !body. has_free_regions( ) , "Free regions in MIR for CTFE" ) ;
418
420
419
- remap_mir_for_const_eval_select ( tcx , body, hir :: Constness :: Const )
421
+ body
420
422
}
421
423
422
424
/// Obtain just the main MIR (no promoteds) and run some cleanups on it. This also runs
@@ -620,14 +622,15 @@ fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> {
620
622
Some ( other) => panic ! ( "do not use `optimized_mir` for constants: {:?}" , other) ,
621
623
}
622
624
debug ! ( "about to call mir_drops_elaborated..." ) ;
623
- let mut body =
625
+ let body =
624
626
tcx. mir_drops_elaborated_and_const_checked ( ty:: WithOptConstParam :: unknown ( did) ) . steal ( ) ;
627
+ let mut body = remap_mir_for_const_eval_select ( tcx, body, hir:: Constness :: NotConst ) ;
625
628
debug ! ( "body: {:#?}" , body) ;
626
629
run_optimization_passes ( tcx, & mut body) ;
627
630
628
631
debug_assert ! ( !body. has_free_regions( ) , "Free regions in optimized MIR" ) ;
629
632
630
- remap_mir_for_const_eval_select ( tcx , body, hir :: Constness :: NotConst )
633
+ body
631
634
}
632
635
633
636
/// Fetch all the promoteds of an item and prepare their MIR bodies to be ready for
0 commit comments