Skip to content

Commit 2a52dc4

Browse files
committed
Avoid leaking the query-job collection warning into panic output
`collect_active_query_jobs` with `CollectActiveJobsKind::PartialAllowed` is only used to print the query stack when the compiler panics. It intentionally skips any query state shard whose lock it cannot take without waiting, since a complete job map is not needed for that. Under the parallel front-end another thread can still hold a shard lock while the panic is being reported, so the skip happens nondeterministically and the `warn!` was printed into the panic output. Because warnings are shown by default, this leaked a "Failed to collect active jobs" line into the diagnostics of panicking compilations and made their output unstable. Lower the message to `debug!` so it stays available with `RUSTC_LOG` but no longer pollutes the default output.
1 parent d595fce commit 2a52dc4

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

compiler/rustc_query_impl/src/execution.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_middle::query::{
1414
use rustc_middle::ty::TyCtxt;
1515
use rustc_middle::verify_ich::incremental_verify_ich;
1616
use rustc_span::{DUMMY_SP, Span};
17-
use tracing::warn;
17+
use tracing::debug;
1818

1919
use crate::dep_graph::{DepNode, DepNodeIndex};
2020
use crate::handle_cycle_error;
@@ -100,7 +100,12 @@ fn collect_active_query_jobs_inner<'tcx, C>(
100100
for shard in query.state.active.try_lock_shards() {
101101
match shard {
102102
Some(shard) => collect_shard_jobs(&shard),
103-
None => warn!("Failed to collect active jobs for query `{}`!", query.name),
103+
// This collection is best-effort (it is only used to print the query
104+
// stack on panic), so a contended shard is expected and fine to skip.
105+
// Emitting this at `warn!` would leak nondeterministically into the
106+
// panic output under the parallel front-end, where another thread may
107+
// still hold a shard lock, so keep it at `debug!`.
108+
None => debug!("Failed to collect active jobs for query `{}`!", query.name),
104109
}
105110
}
106111
}

0 commit comments

Comments
 (0)