Streamline active job collection.

`collect_active_jobs_from_all_queries` takes a `require_complete` bool,
and then some callers `expect` a full map result while others allow a
partial map result. The end result is four possible combinations, but
only three of them are used/make sense.

This commit introduces `CollectActiveJobsKind`, a three-value enum that
describes the three sensible combinations, and rewrites
`collect_active_jobs_from_all_queries` around it. This makes it and its
call sites much clearer, and removes the weird `Option<()>` and
`Result<QueryJobMap, QueryJobMap>` return types.

Other changes of note.
- `active` is removed. The comment about `make_frame` is out of date,
  and `create_deferred_query_stack_frame` *is* safe to call with the
  query state locked.
- When shard locking failure is allowed, collection no longer stops on
  the first failed shard.
This commit is contained in:
Nicholas Nethercote
2026-03-11 17:20:51 +11:00
parent eaf4e7489b
commit 834b7e7e43
5 changed files with 66 additions and 62 deletions
+6 -4
View File
@@ -18,7 +18,7 @@
use rustc_metadata::{DylibError, EncodedMetadata, load_symbol_from_dylib};
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::ty::{CurrentGcx, TyCtxt};
use rustc_query_impl::collect_active_jobs_from_all_queries;
use rustc_query_impl::{CollectActiveJobsKind, collect_active_jobs_from_all_queries};
use rustc_session::config::{
Cfg, CrateType, OutFileName, OutputFilenames, OutputTypes, Sysroot, host_tuple,
};
@@ -253,9 +253,11 @@ pub(crate) fn run_in_thread_pool_with_globals<
unsafe { &*(session_globals as *const SessionGlobals) },
|| {
// Ensure there were no errors collecting all active jobs.
// We need the complete map to ensure we find a cycle to break.
collect_active_jobs_from_all_queries(tcx, false).expect(
"failed to collect active queries in deadlock handler",
// We need the complete map to ensure we find a cycle to
// break.
collect_active_jobs_from_all_queries(
tcx,
CollectActiveJobsKind::FullNoContention,
)
},
);