@@ -517,34 +517,26 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
517517
518518fn optimized_mir < ' tcx > ( tcx : TyCtxt < ' tcx > , did : DefId ) -> & ' tcx Body < ' tcx > {
519519 let did = did. expect_local ( ) ;
520- if let Some ( def) = ty:: WithOptConstParam :: try_lookup ( did, tcx) {
521- tcx. mir_for_ctfe_of_const_arg ( def)
522- } else {
523- tcx. arena . alloc ( inner_optimized_mir ( tcx, ty:: WithOptConstParam :: unknown ( did) ) )
524- }
520+ assert_eq ! ( ty:: WithOptConstParam :: try_lookup( did, tcx) , None ) ;
521+ tcx. arena . alloc ( inner_optimized_mir ( tcx, did) )
525522}
526523
527- fn inner_optimized_mir ( tcx : TyCtxt < ' _ > , def : ty :: WithOptConstParam < LocalDefId > ) -> Body < ' _ > {
528- if tcx. is_constructor ( def . did . to_def_id ( ) ) {
524+ fn inner_optimized_mir ( tcx : TyCtxt < ' _ > , did : LocalDefId ) -> Body < ' _ > {
525+ if tcx. is_constructor ( did. to_def_id ( ) ) {
529526 // There's no reason to run all of the MIR passes on constructors when
530527 // we can just output the MIR we want directly. This also saves const
531528 // qualification and borrow checking the trouble of special casing
532529 // constructors.
533- return shim:: build_adt_ctor ( tcx, def . did . to_def_id ( ) ) ;
530+ return shim:: build_adt_ctor ( tcx, did. to_def_id ( ) ) ;
534531 }
535532
536- match tcx. hir ( ) . body_const_context ( def. did ) {
537- Some ( hir:: ConstContext :: ConstFn ) => {
538- if let Some ( ( did, param_did) ) = def. to_global ( ) . as_const_arg ( ) {
539- tcx. ensure ( ) . mir_for_ctfe_of_const_arg ( ( did, param_did) )
540- } else {
541- tcx. ensure ( ) . mir_for_ctfe ( def. did )
542- }
543- }
533+ match tcx. hir ( ) . body_const_context ( did) {
534+ Some ( hir:: ConstContext :: ConstFn ) => tcx. ensure ( ) . mir_for_ctfe ( did) ,
544535 None => { }
545536 Some ( other) => panic ! ( "do not use `optimized_mir` for constants: {:?}" , other) ,
546537 }
547- let mut body = tcx. mir_drops_elaborated_and_const_checked ( def) . steal ( ) ;
538+ let mut body =
539+ tcx. mir_drops_elaborated_and_const_checked ( ty:: WithOptConstParam :: unknown ( did) ) . steal ( ) ;
548540 run_optimization_passes ( tcx, & mut body) ;
549541
550542 debug_assert ! ( !body. has_free_regions( ) , "Free regions in optimized MIR" ) ;
0 commit comments