Make thir_tree and thir_flat into hooks
This commit is contained in:
parent
ccfcd950b3
commit
81bf9ae263
@ -102,4 +102,10 @@ fn clone(&self) -> Self { *self }
|
|||||||
/// turn a deserialized `DefPathHash` into its current `DefId`.
|
/// turn a deserialized `DefPathHash` into its current `DefId`.
|
||||||
/// Will fetch a DefId from a DefPathHash for a foreign crate.
|
/// 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;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -474,20 +474,6 @@
|
|||||||
desc { |tcx| "building THIR for `{}`", tcx.def_path_str(key) }
|
desc { |tcx| "building THIR for `{}`", tcx.def_path_str(key) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a THIR tree for debugging.
|
|
||||||
query thir_tree(key: LocalDefId) -> &'tcx String {
|
|
||||||
no_hash
|
|
||||||
arena_cache
|
|
||||||
desc { |tcx| "constructing THIR tree for `{}`", tcx.def_path_str(key) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a list-like THIR representation for debugging.
|
|
||||||
query thir_flat(key: LocalDefId) -> &'tcx String {
|
|
||||||
no_hash
|
|
||||||
arena_cache
|
|
||||||
desc { |tcx| "constructing flat THIR representation for `{}`", tcx.def_path_str(key) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set of all the `DefId`s in this crate that have MIR associated with
|
/// Set of all the `DefId`s in this crate that have MIR associated with
|
||||||
/// them. This includes all the body owners, but also things like struct
|
/// them. This includes all the body owners, but also things like struct
|
||||||
/// constructors.
|
/// constructors.
|
||||||
|
@ -34,6 +34,6 @@ pub fn provide(providers: &mut Providers) {
|
|||||||
build::closure_saved_names_of_captured_variables;
|
build::closure_saved_names_of_captured_variables;
|
||||||
providers.check_unsafety = check_unsafety::check_unsafety;
|
providers.check_unsafety = check_unsafety::check_unsafety;
|
||||||
providers.thir_body = thir::cx::thir_body;
|
providers.thir_body = thir::cx::thir_body;
|
||||||
providers.thir_tree = thir::print::thir_tree;
|
providers.hooks.thir_tree = thir::print::thir_tree;
|
||||||
providers.thir_flat = thir::print::thir_flat;
|
providers.hooks.thir_flat = thir::print::thir_flat;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
use rustc_middle::query::TyCtxtAt;
|
||||||
use rustc_middle::thir::*;
|
use rustc_middle::thir::*;
|
||||||
use rustc_middle::ty::{self, TyCtxt};
|
use rustc_middle::ty;
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
|
|
||||||
pub(crate) fn thir_tree(tcx: TyCtxt<'_>, owner_def: LocalDefId) -> String {
|
pub(crate) fn thir_tree(tcx: TyCtxtAt<'_>, owner_def: LocalDefId) -> String {
|
||||||
match super::cx::thir_body(tcx, owner_def) {
|
match super::cx::thir_body(*tcx, owner_def) {
|
||||||
Ok((thir, _)) => {
|
Ok((thir, _)) => {
|
||||||
let thir = thir.steal();
|
let thir = thir.steal();
|
||||||
let mut printer = ThirPrinter::new(&thir);
|
let mut printer = ThirPrinter::new(&thir);
|
||||||
@ -15,8 +16,8 @@ pub(crate) fn thir_tree(tcx: TyCtxt<'_>, owner_def: LocalDefId) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn thir_flat(tcx: TyCtxt<'_>, owner_def: LocalDefId) -> String {
|
pub(crate) fn thir_flat(tcx: TyCtxtAt<'_>, owner_def: LocalDefId) -> String {
|
||||||
match super::cx::thir_body(tcx, owner_def) {
|
match super::cx::thir_body(*tcx, owner_def) {
|
||||||
Ok((thir, _)) => format!("{:#?}", thir.steal()),
|
Ok((thir, _)) => format!("{:#?}", thir.steal()),
|
||||||
Err(_) => "error".into(),
|
Err(_) => "error".into(),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user