diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2025-03-16 23:59:10 +0100 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2025-03-21 07:37:56 +0100 |
| commit | 077b8d5c370391d428dbb4d3d037f6e51b1349a8 (patch) | |
| tree | e0b7e98899babc4a2fc12ee6731e66488afff3b5 /compiler/rustc_query_impl | |
| parent | 01dc45c10e814c25207995a577359e3f137e78ae (diff) | |
| download | rust-077b8d5c370391d428dbb4d3d037f6e51b1349a8.tar.gz rust-077b8d5c370391d428dbb4d3d037f6e51b1349a8.zip | |
Abort in deadlock handler if we fail to get a query map
Diffstat (limited to 'compiler/rustc_query_impl')
| -rw-r--r-- | compiler/rustc_query_impl/src/plumbing.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 2b8457ace8e..85abb77e53c 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -79,14 +79,15 @@ impl QueryContext for QueryCtxt<'_> { tls::with_related_context(self.tcx, |icx| icx.query) } - fn collect_active_jobs(self) -> QueryMap { + fn collect_active_jobs(self) -> (QueryMap, bool) { let mut jobs = QueryMap::default(); + let mut complete = true; for collect in super::TRY_COLLECT_ACTIVE_JOBS.iter() { - collect(self.tcx, &mut jobs); + collect(self.tcx, &mut jobs, &mut complete); } - jobs + (jobs, complete) } // Interactions with on_disk_cache @@ -139,7 +140,8 @@ impl QueryContext for QueryCtxt<'_> { } fn depth_limit_error(self, job: QueryJobId) { - let (info, depth) = job.find_dep_kind_root(self.collect_active_jobs()); + // FIXME: `collect_active_jobs` expects no locks to be held, which doesn't hold for this call. + let (info, depth) = job.find_dep_kind_root(self.collect_active_jobs().0); let suggested_limit = match self.recursion_limit() { Limit(0) => Limit(2), @@ -677,7 +679,7 @@ macro_rules! define_queries { } } - pub(crate) fn try_collect_active_jobs<'tcx>(tcx: TyCtxt<'tcx>, qmap: &mut QueryMap) { + pub(crate) fn try_collect_active_jobs<'tcx>(tcx: TyCtxt<'tcx>, qmap: &mut QueryMap, complete: &mut bool) { let make_query = |tcx, key| { let kind = rustc_middle::dep_graph::dep_kinds::$name; let name = stringify!($name); @@ -692,6 +694,7 @@ macro_rules! define_queries { // don't `unwrap()` here, just manually check for `None` and do best-effort error // reporting. if res.is_none() { + *complete = false; tracing::warn!( "Failed to collect active jobs for query with name `{}`!", stringify!($name) @@ -756,7 +759,7 @@ macro_rules! define_queries { // These arrays are used for iteration and can't be indexed by `DepKind`. - const TRY_COLLECT_ACTIVE_JOBS: &[for<'tcx> fn(TyCtxt<'tcx>, &mut QueryMap)] = + const TRY_COLLECT_ACTIVE_JOBS: &[for<'tcx> fn(TyCtxt<'tcx>, &mut QueryMap, &mut bool)] = &[$(query_impl::$name::try_collect_active_jobs),*]; const ALLOC_SELF_PROFILE_QUERY_STRINGS: &[ |
