about summary refs log tree commit diff
path: root/compiler/rustc_query_system/src/query/config.rs
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-03-27 15:57:22 +1100
committerGitHub <noreply@github.com>2025-03-27 15:57:22 +1100
commit7853b884233d809b9cad8d2909793c5ffdd0e8ac (patch)
tree0128e775632c6c17684649aeae2ba319a61f0df0 /compiler/rustc_query_system/src/query/config.rs
parenta07f0d7465cf8824d3e233fdced98d7c3495ef9c (diff)
parent6ca2af6434ec40ae91207628722fe6e731f6f358 (diff)
downloadrust-7853b884233d809b9cad8d2909793c5ffdd0e8ac.tar.gz
rust-7853b884233d809b9cad8d2909793c5ffdd0e8ac.zip
Rollup merge of #138672 - Zoxc:deferred-queries-in-deadlock-handler, r=oli-obk
Avoiding calling queries when collecting active queries

This PR changes active query collection to no longer call queries. Instead the fields needing queries have their computation delayed to when an cycle error is emitted or when printing the query backtrace in a panic.

This is done by splitting the fields in `QueryStackFrame` needing queries into a new `QueryStackFrameExtra` type. When collecting queries `QueryStackFrame` will contain a closure that can create `QueryStackFrameExtra`, which does make use of queries. Calling `lift` on a `QueryStackFrame` or `CycleError` will convert it to a variant containing `QueryStackFrameExtra` using those closures.

This also only calls queries needed to collect information on a cycle errors, instead of information on all active queries.

Calling queries when collecting active queries is a bit odd. Calling queries should not be done in the deadlock handler at all.

This avoids the out of memory scenario in https://github.com/rust-lang/rust/issues/124901.
Diffstat (limited to 'compiler/rustc_query_system/src/query/config.rs')
-rw-r--r--compiler/rustc_query_system/src/query/config.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_query_system/src/query/config.rs b/compiler/rustc_query_system/src/query/config.rs
index 371b896400a..e508eadb73b 100644
--- a/compiler/rustc_query_system/src/query/config.rs
+++ b/compiler/rustc_query_system/src/query/config.rs
@@ -6,6 +6,7 @@ use std::hash::Hash;
 use rustc_data_structures::fingerprint::Fingerprint;
 use rustc_span::ErrorGuaranteed;
 
+use super::QueryStackFrameExtra;
 use crate::dep_graph::{DepKind, DepNode, DepNodeParams, SerializedDepNodeIndex};
 use crate::error::HandleCycleError;
 use crate::ich::StableHashingContext;
@@ -27,7 +28,7 @@ pub trait QueryConfig<Qcx: QueryContext>: Copy {
     fn format_value(self) -> fn(&Self::Value) -> String;
 
     // Don't use this method to access query results, instead use the methods on TyCtxt
-    fn query_state<'a>(self, tcx: Qcx) -> &'a QueryState<Self::Key>
+    fn query_state<'a>(self, tcx: Qcx) -> &'a QueryState<Self::Key, Qcx::QueryInfo>
     where
         Qcx: 'a;
 
@@ -57,7 +58,7 @@ pub trait QueryConfig<Qcx: QueryContext>: Copy {
     fn value_from_cycle_error(
         self,
         tcx: Qcx::DepContext,
-        cycle_error: &CycleError,
+        cycle_error: &CycleError<QueryStackFrameExtra>,
         guar: ErrorGuaranteed,
     ) -> Self::Value;