@@ -338,38 +338,9 @@ fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> {
338338 return shim:: build_adt_ctor ( tcx, def. to_def_id ( ) ) ;
339339 }
340340
341- let context = tcx
342- . hir ( )
343- . body_const_context ( def)
344- . expect ( "mir_for_ctfe should not be used for runtime functions" ) ;
345-
346341 let body = tcx. mir_drops_elaborated_and_const_checked ( def) . borrow ( ) . clone ( ) ;
347342
348343 let mut body = remap_mir_for_const_eval_select ( tcx, body, hir:: Constness :: Const ) ;
349-
350- match context {
351- // Do not const prop functions, either they get executed at runtime or exported to metadata,
352- // so we run const prop on them, or they don't, in which case we const evaluate some control
353- // flow paths of the function and any errors in those paths will get emitted as const eval
354- // errors.
355- hir:: ConstContext :: ConstFn => { }
356- // Static items always get evaluated, so we can just let const eval see if any erroneous
357- // control flow paths get executed.
358- hir:: ConstContext :: Static ( _) => { }
359- // Associated constants get const prop run so we detect common failure situations in the
360- // crate that defined the constant.
361- // Technically we want to not run on regular const items, but oli-obk doesn't know how to
362- // conveniently detect that at this point without looking at the HIR.
363- hir:: ConstContext :: Const => {
364- pm:: run_passes (
365- tcx,
366- & mut body,
367- & [ & const_prop:: ConstProp ] ,
368- Some ( MirPhase :: Runtime ( RuntimePhase :: Optimized ) ) ,
369- ) ;
370- }
371- }
372-
373344 pm:: run_passes ( tcx, & mut body, & [ & ctfe_limit:: CtfeLimit ] , None ) ;
374345
375346 body
0 commit comments