Skip to content

Commit 6629fe6

Browse files
Rollup merge of #123995 - compiler-errors:thir-hooks, r=oli-obk
Make `thir_tree` and `thir_flat` into hooks No need for them to be queries, since they are only called with `-Zunpretty`
2 parents 24cdb7e + 81bf9ae commit 6629fe6

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

compiler/rustc_middle/src/hooks/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,10 @@ declare_hooks! {
102102
/// turn a deserialized `DefPathHash` into its current `DefId`.
103103
/// Will fetch a DefId from a DefPathHash for a foreign crate.
104104
hook def_path_hash_to_def_id_extern(hash: DefPathHash, stable_crate_id: StableCrateId) -> DefId;
105+
106+
/// Create a THIR tree for debugging.
107+
hook thir_tree(key: LocalDefId) -> String;
108+
109+
/// Create a list-like THIR representation for debugging.
110+
hook thir_flat(key: LocalDefId) -> String;
105111
}

compiler/rustc_middle/src/query/mod.rs

-14
Original file line numberDiff line numberDiff line change
@@ -474,20 +474,6 @@ rustc_queries! {
474474
desc { |tcx| "building THIR for `{}`", tcx.def_path_str(key) }
475475
}
476476

477-
/// Create a THIR tree for debugging.
478-
query thir_tree(key: LocalDefId) -> &'tcx String {
479-
no_hash
480-
arena_cache
481-
desc { |tcx| "constructing THIR tree for `{}`", tcx.def_path_str(key) }
482-
}
483-
484-
/// Create a list-like THIR representation for debugging.
485-
query thir_flat(key: LocalDefId) -> &'tcx String {
486-
no_hash
487-
arena_cache
488-
desc { |tcx| "constructing flat THIR representation for `{}`", tcx.def_path_str(key) }
489-
}
490-
491477
/// Set of all the `DefId`s in this crate that have MIR associated with
492478
/// them. This includes all the body owners, but also things like struct
493479
/// constructors.

compiler/rustc_mir_build/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ pub fn provide(providers: &mut Providers) {
3434
build::closure_saved_names_of_captured_variables;
3535
providers.check_unsafety = check_unsafety::check_unsafety;
3636
providers.thir_body = thir::cx::thir_body;
37-
providers.thir_tree = thir::print::thir_tree;
38-
providers.thir_flat = thir::print::thir_flat;
37+
providers.hooks.thir_tree = thir::print::thir_tree;
38+
providers.hooks.thir_flat = thir::print::thir_flat;
3939
}

compiler/rustc_mir_build/src/thir/print.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
use rustc_middle::query::TyCtxtAt;
12
use rustc_middle::thir::*;
2-
use rustc_middle::ty::{self, TyCtxt};
3+
use rustc_middle::ty;
34
use rustc_span::def_id::LocalDefId;
45
use std::fmt::{self, Write};
56

6-
pub(crate) fn thir_tree(tcx: TyCtxt<'_>, owner_def: LocalDefId) -> String {
7-
match super::cx::thir_body(tcx, owner_def) {
7+
pub(crate) fn thir_tree(tcx: TyCtxtAt<'_>, owner_def: LocalDefId) -> String {
8+
match super::cx::thir_body(*tcx, owner_def) {
89
Ok((thir, _)) => {
910
let thir = thir.steal();
1011
let mut printer = ThirPrinter::new(&thir);
@@ -15,8 +16,8 @@ pub(crate) fn thir_tree(tcx: TyCtxt<'_>, owner_def: LocalDefId) -> String {
1516
}
1617
}
1718

18-
pub(crate) fn thir_flat(tcx: TyCtxt<'_>, owner_def: LocalDefId) -> String {
19-
match super::cx::thir_body(tcx, owner_def) {
19+
pub(crate) fn thir_flat(tcx: TyCtxtAt<'_>, owner_def: LocalDefId) -> String {
20+
match super::cx::thir_body(*tcx, owner_def) {
2021
Ok((thir, _)) => format!("{:#?}", thir.steal()),
2122
Err(_) => "error".into(),
2223
}

0 commit comments

Comments
 (0)