Skip to content

Commit 1d2cb61

Browse files
committed
Remove the mir_build hook.
It was downgraded from a query in rust-lang#122721 but it can just be a vanilla function because it's not called in `rustc_middle`.
1 parent 4b025ca commit 1d2cb61

File tree

5 files changed

+7
-14
lines changed

5 files changed

+7
-14
lines changed

compiler/rustc_middle/src/hooks/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@ declare_hooks! {
7575
/// (Eligible functions might nevertheless be skipped for other reasons.)
7676
hook is_eligible_for_coverage(key: LocalDefId) -> bool;
7777

78-
/// Create the MIR for a given `DefId` - this includes
79-
/// unreachable code.
80-
/// You do not want to call this yourself, instead use the cached version
81-
/// via `mir_built`
82-
hook build_mir(key: LocalDefId) -> mir::Body<'tcx>;
83-
8478
/// Imports all `SourceFile`s from the given crate into the current session.
8579
/// This normally happens automatically when we decode a `Span` from
8680
/// that crate's metadata - however, the incr comp cache needs

compiler/rustc_mir_build/src/builder/custom/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! present, and if so we branch off into this module, which implements the attribute by
77
//! implementing a custom lowering from THIR to MIR.
88
//!
9-
//! The result of this lowering is returned "normally" from the `build_mir` hook, with the only
9+
//! The result of this lowering is returned "normally" from `build_mir`, with the only
1010
//! notable difference being that the `injected` field in the body is set. Various components of the
1111
//! MIR pipeline, like borrowck and the pass manager will then consult this field (via
1212
//! `body.should_skip()`) to skip the parts of the MIR pipeline that precede the MIR phase the user

compiler/rustc_mir_build/src/builder/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
2020
use rustc_middle::hir::place::PlaceBase as HirPlaceBase;
2121
use rustc_middle::middle::region;
2222
use rustc_middle::mir::*;
23-
use rustc_middle::query::TyCtxtAt;
2423
use rustc_middle::thir::{self, ExprId, LintLevel, LocalVarId, Param, ParamId, PatKind, Thir};
2524
use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt, TypeVisitableExt, TypingMode};
2625
use rustc_middle::{bug, span_bug};
@@ -45,9 +44,9 @@ pub(crate) fn closure_saved_names_of_captured_variables<'tcx>(
4544
.collect()
4645
}
4746

48-
/// Construct the MIR for a given `DefId`.
49-
pub(crate) fn build_mir<'tcx>(tcx: TyCtxtAt<'tcx>, def: LocalDefId) -> Body<'tcx> {
50-
let tcx = tcx.tcx;
47+
/// Create the MIR for a given `DefId`, including unreachable code. Do not call
48+
/// this directly; instead use the cached version via `mir_built`.
49+
pub fn build_mir<'tcx>(tcx: TyCtxt<'tcx>, def: LocalDefId) -> Body<'tcx> {
5150
tcx.ensure_with_value().thir_abstract_const(def);
5251
if let Err(e) = tcx.check_match(def) {
5352
return construct_error(tcx, def, e);

compiler/rustc_mir_build/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// The `builder` module used to be named `build`, but that was causing GitHub's
1515
// "Go to file" feature to silently ignore all files in the module, probably
1616
// because it assumes that "build" is a build-output directory. See #134365.
17-
mod builder;
17+
pub mod builder;
1818
mod check_tail_calls;
1919
mod check_unsafety;
2020
mod errors;
@@ -27,7 +27,6 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
2727
pub fn provide(providers: &mut Providers) {
2828
providers.check_match = thir::pattern::check_match;
2929
providers.lit_to_const = thir::constant::lit_to_const;
30-
providers.hooks.build_mir = builder::build_mir;
3130
providers.closure_saved_names_of_captured_variables =
3231
builder::closure_saved_names_of_captured_variables;
3332
providers.check_unsafety = check_unsafety::check_unsafety;

compiler/rustc_mir_transform/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use rustc_middle::mir::{
3333
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
3434
use rustc_middle::util::Providers;
3535
use rustc_middle::{bug, query, span_bug};
36+
use rustc_mir_build::builder::build_mir;
3637
use rustc_span::source_map::Spanned;
3738
use rustc_span::{DUMMY_SP, sym};
3839
use tracing::debug;
@@ -368,7 +369,7 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def: LocalDefId) -> ConstQualifs {
368369
}
369370

370371
fn mir_built(tcx: TyCtxt<'_>, def: LocalDefId) -> &Steal<Body<'_>> {
371-
let mut body = tcx.build_mir(def);
372+
let mut body = build_mir(tcx, def);
372373

373374
pass_manager::dump_mir_for_phase_change(tcx, &body);
374375

0 commit comments

Comments
 (0)