about summary refs log tree commit diff
path: root/compiler/rustc_query_impl/src
diff options
context:
space:
mode:
authorFelix Rath <felixm.rath@gmail.com>2024-08-12 03:16:39 +0200
committerFelix Rath <felixm.rath@gmail.com>2024-08-19 17:42:42 +0200
commit2bf24559252f9e4a186ea6227827c0c7c417471a (patch)
tree37205a4907696f338a936d91fbc9f6e41f6bcf56 /compiler/rustc_query_impl/src
parente3f909b2bbd0b10db6f164d466db237c582d3045 (diff)
downloadrust-2bf24559252f9e4a186ea6227827c0c7c417471a.tar.gz
rust-2bf24559252f9e4a186ea6227827c0c7c417471a.zip
Prevent double panic in query system, improve diagnostics
Diffstat (limited to 'compiler/rustc_query_impl/src')
-rw-r--r--compiler/rustc_query_impl/src/plumbing.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs
index b9e700c1938..c064b2bd6c1 100644
--- a/compiler/rustc_query_impl/src/plumbing.rs
+++ b/compiler/rustc_query_impl/src/plumbing.rs
@@ -702,11 +702,17 @@ macro_rules! define_queries {
                     let name = stringify!($name);
                     $crate::plumbing::create_query_frame(tcx, rustc_middle::query::descs::$name, key, kind, name)
                 };
-                tcx.query_system.states.$name.try_collect_active_jobs(
+                let res = tcx.query_system.states.$name.try_collect_active_jobs(
                     tcx,
                     make_query,
                     qmap,
-                ).unwrap();
+                );
+                // this can be called during unwinding, and the function has a `try_`-prefix, so
+                // don't `unwrap()` here, just manually check for `None` and do best-effort error
+                // reporting.
+                if res.is_none() {
+                    tracing::warn!("Failed to collect active jobs for query with name `{}`!", stringify!($name));
+                }
             }
 
             pub fn alloc_self_profile_query_strings<'tcx>(tcx: TyCtxt<'tcx>, string_cache: &mut QueryKeyStringCache) {