Update comments

This commit is contained in:
John Kåre Alsaker 2025-03-18 14:36:28 +01:00
parent 077b8d5c37
commit 157008d711
3 changed files with 8 additions and 2 deletions

View file

@ -195,9 +195,10 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce(CurrentGcx) -> R + Send,
tls::with(|tcx| {
let (query_map, complete) = QueryCtxt::new(tcx).collect_active_jobs();
if !complete {
// There was an unexpected error collecting all active jobs, which we need
// to find cycles to break.
// We want to avoid panicking in the deadlock handler, so we abort instead.
eprintln!("internal compiler error: failed to get query map in deadlock handler, aborting process");
// We need to abort here as we failed to resolve the deadlock,
// otherwise the compiler could just hang,
process::abort();
}
query_map

View file

@ -79,6 +79,8 @@ impl QueryContext for QueryCtxt<'_> {
tls::with_related_context(self.tcx, |icx| icx.query)
}
/// Returns a query map representing active query jobs and a bool being false
/// if there was an error constructing the map.
fn collect_active_jobs(self) -> (QueryMap, bool) {
let mut jobs = QueryMap::default();
let mut complete = true;

View file

@ -251,7 +251,10 @@ where
Qcx: QueryContext,
{
let (query_map, complete) = qcx.collect_active_jobs();
// Ensure there was no errors collecting all active jobs.
// We need the complete map to ensure we find a cycle to break.
assert!(complete, "failed to collect active queries");
let error = try_execute.find_cycle_in_stack(query_map, &qcx.current_query_job(), span);
(mk_cycle(query, qcx, error), None)
}