1
Fork 0

Rollup merge of #77493 - hosseind88:ICEs_should_always_print_the_top_of_the_query_stack, r=oli-obk

ICEs should always print the top of the query stack

see #76920
This commit is contained in:
Dylan DPC 2020-10-16 02:10:09 +02:00 committed by GitHub
commit 0e4d19603b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 34 additions and 13 deletions

View file

@ -124,20 +124,23 @@ impl<'tcx> TyCtxt<'tcx> {
})
}
pub fn try_print_query_stack(handler: &Handler) {
pub fn try_print_query_stack(handler: &Handler, num_frames: Option<usize>) {
eprintln!("query stack during panic:");
// Be careful reyling 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 mut i = 0;
ty::tls::with_context_opt(|icx| {
if let Some(icx) = icx {
let query_map = icx.tcx.queries.try_collect_active_jobs();
let mut current_query = icx.query;
let mut i = 0;
while let Some(query) = current_query {
if Some(i) == num_frames {
break;
}
let query_info =
if let Some(info) = query_map.as_ref().and_then(|map| map.get(&query)) {
info
@ -163,7 +166,11 @@ impl<'tcx> TyCtxt<'tcx> {
}
});
eprintln!("end of query stack");
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");
}
}
}