Skip to content

Commit d568d63

Browse files
committed
Auto merge of #85273 - LeSeulArtichaut:thir-query, r=nikomatsakis
Make building THIR a stealable query This PR creates a stealable `thir_body` query so that we can build the THIR only once for THIR unsafeck and MIR build. Blocked on #83842. r? `@nikomatsakis`
2 parents 126561c + af3d9a3 commit d568d63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+937
-922
lines changed

compiler/rustc_interface/src/passes.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -873,9 +873,8 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
873873

874874
sess.time("MIR_effect_checking", || {
875875
for def_id in tcx.body_owners() {
876-
if tcx.sess.opts.debugging_opts.thir_unsafeck {
877-
tcx.ensure().thir_check_unsafety(def_id);
878-
} else {
876+
tcx.ensure().thir_check_unsafety(def_id);
877+
if !tcx.sess.opts.debugging_opts.thir_unsafeck {
879878
mir::transform::check_unsafety::check_unsafety(tcx, def_id);
880879
}
881880

compiler/rustc_middle/src/arena.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ macro_rules! arena_types {
1414
[] layouts: rustc_target::abi::Layout,
1515
// AdtDef are interned and compared by address
1616
[] adt_def: rustc_middle::ty::AdtDef,
17+
[] steal_thir: rustc_data_structures::steal::Steal<rustc_middle::thir::Thir<$tcx>>,
1718
[] steal_mir: rustc_data_structures::steal::Steal<rustc_middle::mir::Body<$tcx>>,
1819
[decode] mir: rustc_middle::mir::Body<$tcx>,
1920
[] steal_promoted:

compiler/rustc_middle/src/dep_graph/dep_node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub type DepNode = rustc_query_system::dep_graph::DepNode<DepKind>;
285285
// required that their size stay the same, but we don't want to change
286286
// it inadvertently. This assert just ensures we're aware of any change.
287287
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
288-
static_assert_size!(DepNode, 17);
288+
static_assert_size!(DepNode, 18);
289289

290290
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
291291
static_assert_size!(DepNode, 24);

compiler/rustc_middle/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ pub mod infer;
8383
pub mod lint;
8484
pub mod middle;
8585
pub mod mir;
86+
pub mod thir;
8687
pub mod traits;
8788
pub mod ty;
8889

compiler/rustc_middle/src/query/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ rustc_queries! {
220220
desc { "checking if the crate is_panic_runtime" }
221221
}
222222

223+
/// Fetch the THIR for a given body. If typeck for that body failed, returns an empty `Thir`.
224+
query thir_body(key: ty::WithOptConstParam<LocalDefId>) -> (&'tcx Steal<thir::Thir<'tcx>>, thir::ExprId) {
225+
desc { |tcx| "building THIR for `{}`", tcx.def_path_str(key.did.to_def_id()) }
226+
}
227+
223228
/// Set of all the `DefId`s in this crate that have MIR associated with
224229
/// them. This includes all the body owners, but also things like struct
225230
/// constructors.

0 commit comments

Comments
 (0)