diff options
| author | bors <bors@rust-lang.org> | 2025-03-25 19:53:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-03-25 19:53:57 +0000 |
| commit | 43f0014ef0f242418674f49052ed39b70f73bc1c (patch) | |
| tree | 926b46f8a13419513fdceed630a14fe9cf89e089 /compiler/rustc_query_impl | |
| parent | 40507bded561ca6d28f3e187aed8317bb81ce9e2 (diff) | |
| parent | 1107fc7ad22b7a37b6235ca0356390a2fea8be45 (diff) | |
| download | rust-43f0014ef0f242418674f49052ed39b70f73bc1c.tar.gz rust-43f0014ef0f242418674f49052ed39b70f73bc1c.zip | |
Auto merge of #138933 - matthiaskrgr:rollup-sjtqkoq, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #135745 (Recognise new IPv6 non-global range from IETF RFC 9602) - #137247 (cg_llvm: Reduce the visibility of types, modules and using declarations in `rustc_codegen_llvm`.) - #138317 (privacy: Visit types and traits in impls in type privacy lints) - #138581 (Abort in deadlock handler if we fail to get a query map) - #138776 (coverage: Separate span-extraction from unexpansion) - #138886 (Fix autofix for `self` and `self as …` in `unused_imports` lint) - #138924 (Reduce `kw::Empty` usage, part 3) - #138929 (Visitors track whether an assoc item is in a trait impl or an inherent impl) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_query_impl')
| -rw-r--r-- | compiler/rustc_query_impl/src/plumbing.rs | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 6fc7f023cf0..55281cd5ac7 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -79,14 +79,20 @@ impl QueryContext for QueryCtxt<'_> { tls::with_related_context(self.tcx, |icx| icx.query) } - fn collect_active_jobs(self) -> QueryMap { + /// Returns a query map representing active query jobs. + /// It returns an incomplete map as an error if it fails + /// to take locks. + fn collect_active_jobs(self) -> Result<QueryMap, QueryMap> { let mut jobs = QueryMap::default(); + let mut complete = true; for collect in super::TRY_COLLECT_ACTIVE_JOBS.iter() { - collect(self.tcx, &mut jobs); + if collect(self.tcx, &mut jobs).is_none() { + complete = false; + } } - jobs + if complete { Ok(jobs) } else { Err(jobs) } } // Interactions with on_disk_cache @@ -139,7 +145,12 @@ 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 query_map = match self.collect_active_jobs() { + Ok(query_map) => query_map, + Err(query_map) => query_map, + }; + let (info, depth) = job.find_dep_kind_root(query_map); let suggested_limit = match self.recursion_limit() { Limit(0) => Limit(2), @@ -677,7 +688,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) -> Option<()> { let make_query = |tcx, key| { let kind = rustc_middle::dep_graph::dep_kinds::$name; let name = stringify!($name); @@ -697,6 +708,7 @@ macro_rules! define_queries { stringify!($name) ); } + res } pub(crate) fn alloc_self_profile_query_strings<'tcx>( @@ -756,7 +768,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) -> Option<()>] = &[$(query_impl::$name::try_collect_active_jobs),*]; const ALLOC_SELF_PROFILE_QUERY_STRINGS: &[ |
