Skip to content

Commit 4b025ca

Browse files
committed
Remove the thir_{tree,flat} hooks.
They were downgraded from queries in rust-lang#123995 but they can just be vanilla functions because they are not called in `rustc_middle`.
1 parent be1aa7b commit 4b025ca

File tree

5 files changed

+12
-17
lines changed

5 files changed

+12
-17
lines changed

compiler/rustc_driver_impl/src/pretty.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_ast_pretty::pprust as pprust_ast;
77
use rustc_middle::bug;
88
use rustc_middle::mir::{write_mir_graphviz, write_mir_pretty};
99
use rustc_middle::ty::{self, TyCtxt};
10+
use rustc_mir_build::thir::print::{thir_flat, thir_tree};
1011
use rustc_session::Session;
1112
use rustc_session::config::{OutFileName, PpHirMode, PpMode, PpSourceMode};
1213
use rustc_smir::rustc_internal::pretty::write_smir_pretty;
@@ -313,7 +314,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
313314
tcx.dcx().abort_if_errors();
314315
debug!("pretty printing THIR tree");
315316
for did in tcx.hir().body_owners() {
316-
let _ = writeln!(out, "{:?}:\n{}\n", did, tcx.thir_tree(did));
317+
let _ = writeln!(out, "{:?}:\n{}\n", did, thir_tree(tcx, did));
317318
}
318319
out
319320
}
@@ -324,7 +325,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
324325
tcx.dcx().abort_if_errors();
325326
debug!("pretty printing THIR flat");
326327
for did in tcx.hir().body_owners() {
327-
let _ = writeln!(out, "{:?}:\n{}\n", did, tcx.thir_flat(did));
328+
let _ = writeln!(out, "{:?}:\n{}\n", did, thir_flat(tcx, did));
328329
}
329330
out
330331
}

compiler/rustc_middle/src/hooks/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ declare_hooks! {
9999
/// Will fetch a DefId from a DefPathHash for a foreign crate.
100100
hook def_path_hash_to_def_id_extern(hash: DefPathHash, stable_crate_id: StableCrateId) -> DefId;
101101

102-
/// Create a THIR tree for debugging.
103-
hook thir_tree(key: LocalDefId) -> String;
104-
105-
/// Create a list-like THIR representation for debugging.
106-
hook thir_flat(key: LocalDefId) -> String;
107-
108102
/// Returns `true` if we should codegen an instance in the local crate, or returns `false` if we
109103
/// can just link to the upstream crate and therefore don't need a mono item.
110104
///

compiler/rustc_mir_build/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mod builder;
1818
mod check_tail_calls;
1919
mod check_unsafety;
2020
mod errors;
21-
mod thir;
21+
pub mod thir;
2222

2323
use rustc_middle::util::Providers;
2424

@@ -33,6 +33,4 @@ pub fn provide(providers: &mut Providers) {
3333
providers.check_unsafety = check_unsafety::check_unsafety;
3434
providers.check_tail_calls = check_tail_calls::check_tail_calls;
3535
providers.thir_body = thir::cx::thir_body;
36-
providers.hooks.thir_tree = thir::print::thir_tree;
37-
providers.hooks.thir_flat = thir::print::thir_flat;
3836
}

compiler/rustc_mir_build/src/thir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
pub(crate) mod constant;
88
pub(crate) mod cx;
99
pub(crate) mod pattern;
10-
pub(crate) mod print;
10+
pub mod print;
1111
mod util;

compiler/rustc_mir_build/src/thir/print.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use std::fmt::{self, Write};
22

3-
use rustc_middle::query::TyCtxtAt;
43
use rustc_middle::thir::*;
54
use rustc_middle::ty;
5+
use rustc_middle::ty::TyCtxt;
66
use rustc_span::def_id::LocalDefId;
77

8-
pub(crate) fn thir_tree(tcx: TyCtxtAt<'_>, owner_def: LocalDefId) -> String {
9-
match super::cx::thir_body(*tcx, owner_def) {
8+
/// Create a THIR tree for debugging.
9+
pub fn thir_tree(tcx: TyCtxt<'_>, owner_def: LocalDefId) -> String {
10+
match super::cx::thir_body(tcx, owner_def) {
1011
Ok((thir, _)) => {
1112
let thir = thir.steal();
1213
let mut printer = ThirPrinter::new(&thir);
@@ -17,8 +18,9 @@ pub(crate) fn thir_tree(tcx: TyCtxtAt<'_>, owner_def: LocalDefId) -> String {
1718
}
1819
}
1920

20-
pub(crate) fn thir_flat(tcx: TyCtxtAt<'_>, owner_def: LocalDefId) -> String {
21-
match super::cx::thir_body(*tcx, owner_def) {
21+
/// Create a list-like THIR representation for debugging.
22+
pub fn thir_flat(tcx: TyCtxt<'_>, owner_def: LocalDefId) -> String {
23+
match super::cx::thir_body(tcx, owner_def) {
2224
Ok((thir, _)) => format!("{:#?}", thir.steal()),
2325
Err(_) => "error".into(),
2426
}

0 commit comments

Comments
 (0)