Move try_print_query_stack to rustc_interface.
This commit is contained in:
parent
0e9cac40a6
commit
4dbf83a209
4 changed files with 60 additions and 52 deletions
|
@ -8,7 +8,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
|||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_data_structures::OnDrop;
|
||||
use rustc_errors::registry::Registry;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::{ErrorReported, Handler};
|
||||
use rustc_lint::LintStore;
|
||||
use rustc_middle::ty;
|
||||
use rustc_parse::new_parser_from_source_str;
|
||||
|
@ -213,3 +213,24 @@ pub fn run_compiler<R: Send>(mut config: Config, f: impl FnOnce(&Compiler) -> R
|
|||
|| create_compiler_and_run(config, f),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn try_print_query_stack(handler: &Handler, num_frames: Option<usize>) {
|
||||
eprintln!("query stack during panic:");
|
||||
|
||||
// Be careful relying on global state here: this code is called from
|
||||
// a panic hook, which means that the global `Handler` may be in a weird
|
||||
// state if it was responsible for triggering the panic.
|
||||
let i = ty::tls::with_context_opt(|icx| {
|
||||
if let Some(icx) = icx {
|
||||
icx.tcx.queries.try_print_query_stack(icx.tcx, icx.query, handler, num_frames)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
});
|
||||
|
||||
if num_frames == None || num_frames >= Some(i) {
|
||||
eprintln!("end of query stack");
|
||||
} else {
|
||||
eprintln!("we're just showing a limited slice of the query stack");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue