+
+fn mir_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx Steal<Mir<'tcx>> {
+ let mut mir = build::mir_build(tcx, def_id);
+ let source = MirSource::from_local_def_id(tcx, def_id);
+ transform::run_suite(tcx, source, MIR_CONST, &mut mir);
+ tcx.alloc_steal_mir(mir)
+}
+
+fn mir_validated<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx Steal<Mir<'tcx>> {
+ let source = MirSource::from_local_def_id(tcx, def_id);
+ if let MirSource::Const(_) = source {
+ // Ensure that we compute the `mir_const_qualif` for constants at
+ // this point, before we steal the mir-const result. We don't
+ // directly need the result or `mir_const_qualif`, so we can just force it.
+ ty::queries::mir_const_qualif::force(tcx, DUMMY_SP, def_id);
+ }
+
+ let mut mir = tcx.mir_const(def_id).steal();
+ transform::run_suite(tcx, source, MIR_VALIDATED, &mut mir);
+ tcx.alloc_steal_mir(mir)
+}
+
+fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx Mir<'tcx> {
+ let mut mir = tcx.mir_validated(def_id).steal();
+ let source = MirSource::from_local_def_id(tcx, def_id);
+ transform::run_suite(tcx, source, MIR_OPTIMIZED, &mut mir);
+ tcx.alloc_mir(mir)
+}