From 97906bcd5c9c5ba5d165c7330b2ee062a97f11cf Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Thu, 26 Sep 2019 16:55:07 -0400 Subject: [PATCH] Add note about global state in try_print_query_stack --- src/librustc/ty/query/plumbing.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index e2dff46d18b16..d3e6789b826a9 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -325,6 +325,9 @@ impl<'tcx> TyCtxt<'tcx> { pub fn try_print_query_stack(handler: &Handler) { 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. tls::with_context_opt(|icx| { if let Some(icx) = icx { let mut current_query = icx.query.clone();