diff options
| -rw-r--r-- | compiler/rustc_driver_impl/src/pretty.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/hooks/mod.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/lib.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/print.rs | 12 |
5 files changed, 12 insertions, 17 deletions
diff --git a/compiler/rustc_driver_impl/src/pretty.rs b/compiler/rustc_driver_impl/src/pretty.rs index 93f3d2ab911..699742aa0ea 100644 --- a/compiler/rustc_driver_impl/src/pretty.rs +++ b/compiler/rustc_driver_impl/src/pretty.rs @@ -7,6 +7,7 @@ use rustc_ast_pretty::pprust as pprust_ast; use rustc_middle::bug; use rustc_middle::mir::{write_mir_graphviz, write_mir_pretty}; use rustc_middle::ty::{self, TyCtxt}; +use rustc_mir_build::thir::print::{thir_flat, thir_tree}; use rustc_session::Session; use rustc_session::config::{OutFileName, PpHirMode, PpMode, PpSourceMode}; use rustc_smir::rustc_internal::pretty::write_smir_pretty; @@ -313,7 +314,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) { tcx.dcx().abort_if_errors(); debug!("pretty printing THIR tree"); for did in tcx.hir().body_owners() { - let _ = writeln!(out, "{:?}:\n{}\n", did, tcx.thir_tree(did)); + let _ = writeln!(out, "{:?}:\n{}\n", did, thir_tree(tcx, did)); } out } @@ -324,7 +325,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) { tcx.dcx().abort_if_errors(); debug!("pretty printing THIR flat"); for did in tcx.hir().body_owners() { - let _ = writeln!(out, "{:?}:\n{}\n", did, tcx.thir_flat(did)); + let _ = writeln!(out, "{:?}:\n{}\n", did, thir_flat(tcx, did)); } out } diff --git a/compiler/rustc_middle/src/hooks/mod.rs b/compiler/rustc_middle/src/hooks/mod.rs index f546bf6cad5..03bbac342eb 100644 --- a/compiler/rustc_middle/src/hooks/mod.rs +++ b/compiler/rustc_middle/src/hooks/mod.rs @@ -99,12 +99,6 @@ declare_hooks! { /// Will fetch a DefId from a DefPathHash for a foreign crate. hook def_path_hash_to_def_id_extern(hash: DefPathHash, stable_crate_id: StableCrateId) -> DefId; - /// Create a THIR tree for debugging. - hook thir_tree(key: LocalDefId) -> String; - - /// Create a list-like THIR representation for debugging. - hook thir_flat(key: LocalDefId) -> String; - /// Returns `true` if we should codegen an instance in the local crate, or returns `false` if we /// can just link to the upstream crate and therefore don't need a mono item. /// diff --git a/compiler/rustc_mir_build/src/lib.rs b/compiler/rustc_mir_build/src/lib.rs index 8e786733ee0..d8e541217be 100644 --- a/compiler/rustc_mir_build/src/lib.rs +++ b/compiler/rustc_mir_build/src/lib.rs @@ -18,7 +18,7 @@ mod builder; mod check_tail_calls; mod check_unsafety; mod errors; -mod thir; +pub mod thir; use rustc_middle::util::Providers; @@ -33,6 +33,4 @@ pub fn provide(providers: &mut Providers) { providers.check_unsafety = check_unsafety::check_unsafety; providers.check_tail_calls = check_tail_calls::check_tail_calls; providers.thir_body = thir::cx::thir_body; - providers.hooks.thir_tree = thir::print::thir_tree; - providers.hooks.thir_flat = thir::print::thir_flat; } diff --git a/compiler/rustc_mir_build/src/thir/mod.rs b/compiler/rustc_mir_build/src/thir/mod.rs index ca26cc13b5e..c7c88801d4d 100644 --- a/compiler/rustc_mir_build/src/thir/mod.rs +++ b/compiler/rustc_mir_build/src/thir/mod.rs @@ -7,5 +7,5 @@ pub(crate) mod constant; pub(crate) mod cx; pub(crate) mod pattern; -pub(crate) mod print; +pub mod print; mod util; diff --git a/compiler/rustc_mir_build/src/thir/print.rs b/compiler/rustc_mir_build/src/thir/print.rs index 2bcdb67c58a..228a64c2c70 100644 --- a/compiler/rustc_mir_build/src/thir/print.rs +++ b/compiler/rustc_mir_build/src/thir/print.rs @@ -1,12 +1,13 @@ use std::fmt::{self, Write}; -use rustc_middle::query::TyCtxtAt; use rustc_middle::thir::*; use rustc_middle::ty; +use rustc_middle::ty::TyCtxt; use rustc_span::def_id::LocalDefId; -pub(crate) fn thir_tree(tcx: TyCtxtAt<'_>, owner_def: LocalDefId) -> String { - match super::cx::thir_body(*tcx, owner_def) { +/// Create a THIR tree for debugging. +pub fn thir_tree(tcx: TyCtxt<'_>, owner_def: LocalDefId) -> String { + match super::cx::thir_body(tcx, owner_def) { Ok((thir, _)) => { let thir = thir.steal(); let mut printer = ThirPrinter::new(&thir); @@ -17,8 +18,9 @@ pub(crate) fn thir_tree(tcx: TyCtxtAt<'_>, owner_def: LocalDefId) -> String { } } -pub(crate) fn thir_flat(tcx: TyCtxtAt<'_>, owner_def: LocalDefId) -> String { - match super::cx::thir_body(*tcx, owner_def) { +/// Create a list-like THIR representation for debugging. +pub fn thir_flat(tcx: TyCtxt<'_>, owner_def: LocalDefId) -> String { + match super::cx::thir_body(tcx, owner_def) { Ok((thir, _)) => format!("{:#?}", thir.steal()), Err(_) => "error".into(), } |
