@@ -289,19 +289,19 @@ pub fn write_mir_pretty<'tcx>(
289
289
}
290
290
Ok ( ( ) )
291
291
} ;
292
- match tcx . hir ( ) . body_const_context ( def_id . expect_local ( ) ) {
293
- None => render_body ( w , tcx . optimized_mir ( def_id ) ) ? ,
294
- // For `const fn` we want to render the optimized MIR. If you want the mir used in
295
- // ctfe, you can dump the MIR after the `Deaggregator` optimization pass.
296
- Some ( rustc_hir :: ConstContext :: ConstFn ) => {
297
- render_body ( w, tcx . optimized_mir ( def_id ) ) ?;
298
- writeln ! ( w ) ? ;
299
- writeln ! ( w , "// MIR FOR CTFE" ) ? ;
300
- // Do not use `render_body`, as that would render the promoteds again, but these
301
- // are shared between mir_for_ctfe and optimized_mir
302
- write_mir_fn ( tcx , tcx . mir_for_ctfe ( def_id ) , & mut |_ , _| Ok ( ( ) ) , w ) ? ;
303
- }
304
- Some ( _ ) => render_body ( w, tcx . mir_for_ctfe ( def_id ) ) ? ,
292
+
293
+ // For `const fn` we want to render both the optimized MIR and the MIR for ctfe.
294
+ if tcx . is_const_fn_raw ( def_id ) {
295
+ render_body ( w , tcx . optimized_mir ( def_id ) ) ? ;
296
+ writeln ! ( w ) ? ;
297
+ writeln ! ( w, "// MIR FOR CTFE" ) ?;
298
+ // Do not use `render_body`, as that would render the promoteds again, but these
299
+ // are shared between mir_for_ctfe and optimized_mir
300
+ write_mir_fn ( tcx , tcx . mir_for_ctfe ( def_id ) , & mut |_ , _| Ok ( ( ) ) , w ) ? ;
301
+ } else {
302
+ let instance_mir =
303
+ tcx . instance_mir ( ty :: InstanceDef :: Item ( ty :: WithOptConstParam :: unknown ( def_id ) ) ) ;
304
+ render_body ( w, instance_mir ) ? ;
305
305
}
306
306
}
307
307
Ok ( ( ) )
0 commit comments