Skip to content

Commit

Permalink
dump query_stack
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleywiser committed Feb 19, 2020
1 parent fc23a81 commit 6f74606
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/librustc/mir/interpret/error.rs
Expand Up @@ -4,6 +4,7 @@ use crate::hir::map::definitions::DefPathData;
use crate::mir;
use crate::ty::layout::{Align, LayoutError, Size};
use crate::ty::query::TyCtxtAt;
use crate::ty::tls;
use crate::ty::{self, layout, Ty};

use backtrace::Backtrace;
Expand Down Expand Up @@ -246,6 +247,25 @@ impl<'tcx> From<InterpError<'tcx>> for InterpErrorInfo<'tcx> {
Ok(ref val) if val != "0" => {
let mut backtrace = Backtrace::new_unresolved();

if val == "2" {
// print query stack
tls::with_context_opt(|ctxt| {
if let Some(ctxt) = ctxt {
let mut s = String::new();
let mut query = ctxt.query.clone();

while let Some(q) = query {
s.push_str(q.info.query.name());
s.push_str(", ");

query = q.parent.clone();
}

eprintln!("{}", s);
}
})
}

if val == "immediate" {
// Print it now.
print_backtrace(&mut backtrace);
Expand Down

0 comments on commit 6f74606

Please sign in to comment.