about summary refs log tree commit diff
path: root/compiler/rustc_query_system/src
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2025-03-14 18:36:30 +0100
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2025-03-14 18:39:27 +0100
commit453b51a65ab00939d2dce3de24ce38489b5c7eb6 (patch)
treea3339fa266b7b0a56283c7e49e2b03ac0b427579 /compiler/rustc_query_system/src
parent3ca5220114c1e690d876aa46c3aa0f6ec594b9c5 (diff)
downloadrust-453b51a65ab00939d2dce3de24ce38489b5c7eb6.tar.gz
rust-453b51a65ab00939d2dce3de24ce38489b5c7eb6.zip
Rename `QuerySideEffects` to `QuerySideEffect`
Diffstat (limited to 'compiler/rustc_query_system/src')
-rw-r--r--compiler/rustc_query_system/src/dep_graph/graph.rs16
-rw-r--r--compiler/rustc_query_system/src/query/mod.rs26
2 files changed, 25 insertions, 17 deletions
diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs
index de681328bcb..dbc7f034a6e 100644
--- a/compiler/rustc_query_system/src/dep_graph/graph.rs
+++ b/compiler/rustc_query_system/src/dep_graph/graph.rs
@@ -25,7 +25,7 @@ use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex
 use super::{DepContext, DepKind, DepNode, Deps, HasDepContext, WorkProductId};
 use crate::dep_graph::edges::EdgesVec;
 use crate::ich::StableHashingContext;
-use crate::query::{QueryContext, QuerySideEffects};
+use crate::query::{QueryContext, QuerySideEffect};
 
 #[derive(Clone)]
 pub struct DepGraph<D: Deps> {
@@ -689,8 +689,8 @@ impl<D: Deps> DepGraphData<D> {
             // diagnostic.
             std::iter::once(DepNodeIndex::FOREVER_RED_NODE).collect(),
         );
-        let side_effects = QuerySideEffects { diagnostic: diagnostic.clone() };
-        qcx.store_side_effects(dep_node_index, side_effects);
+        let side_effect = QuerySideEffect::Diagnostic(diagnostic.clone());
+        qcx.store_side_effect(dep_node_index, side_effect);
         dep_node_index
     }
 
@@ -701,14 +701,18 @@ impl<D: Deps> DepGraphData<D> {
         prev_index: SerializedDepNodeIndex,
     ) {
         D::with_deps(TaskDepsRef::Ignore, || {
-            let side_effects = qcx.load_side_effects(prev_index).unwrap();
+            let side_effect = qcx.load_side_effect(prev_index).unwrap();
 
-            qcx.dep_context().sess().dcx().emit_diagnostic(side_effects.diagnostic.clone());
+            match &side_effect {
+                QuerySideEffect::Diagnostic(diagnostic) => {
+                    qcx.dep_context().sess().dcx().emit_diagnostic(diagnostic.clone());
+                }
+            }
 
             // Promote the previous diagnostics to the current session.
             let index = self.current.promote_node_and_deps_to_current(&self.previous, prev_index);
             // FIXME: Can this race with a parallel compiler?
-            qcx.store_side_effects(index, side_effects);
+            qcx.store_side_effect(index, side_effect);
 
             // Mark the node as green.
             self.colors.insert(prev_index, DepNodeColor::Green(index));
diff --git a/compiler/rustc_query_system/src/query/mod.rs b/compiler/rustc_query_system/src/query/mod.rs
index ad246b3e8b1..2ed0c810b75 100644
--- a/compiler/rustc_query_system/src/query/mod.rs
+++ b/compiler/rustc_query_system/src/query/mod.rs
@@ -62,18 +62,22 @@ impl QueryStackFrame {
     }
 }
 
-/// Tracks 'side effects' for a particular query.
+/// Track a 'side effects' for a particular query.
 /// This struct is saved to disk along with the query result,
 /// and loaded from disk if we mark the query as green.
 /// This allows us to 'replay' changes to global state
 /// that would otherwise only occur if we actually
 /// executed the query method.
+///
+/// Each side effect gets an unique dep node index which is added
+/// as a dependency of the query which had the effect.
 #[derive(Debug, Encodable, Decodable)]
-pub struct QuerySideEffects {
-    /// Stores any diagnostics emitted during query execution.
-    /// These diagnostics will be re-emitted if we mark
-    /// the query as green.
-    pub(super) diagnostic: DiagInner,
+pub enum QuerySideEffect {
+    /// Stores a diagnostic emitted during query execution.
+    /// This diagnostic will be re-emitted if we mark
+    /// the query as green, as that query will have the side
+    /// effect dep node as a dependency.
+    Diagnostic(DiagInner),
 }
 
 pub trait QueryContext: HasDepContext {
@@ -84,14 +88,14 @@ pub trait QueryContext: HasDepContext {
 
     fn collect_active_jobs(self) -> QueryMap;
 
-    /// Load side effects associated to the node in the previous session.
-    fn load_side_effects(
+    /// Load a side effect associated to the node in the previous session.
+    fn load_side_effect(
         self,
         prev_dep_node_index: SerializedDepNodeIndex,
-    ) -> Option<QuerySideEffects>;
+    ) -> Option<QuerySideEffect>;
 
-    /// Register diagnostics for the given node, for use in next session.
-    fn store_side_effects(self, dep_node_index: DepNodeIndex, side_effects: QuerySideEffects);
+    /// Register a side effect for the given node, for use in next session.
+    fn store_side_effect(self, dep_node_index: DepNodeIndex, side_effect: QuerySideEffect);
 
     /// Executes a job by changing the `ImplicitCtxt` to point to the
     /// new query job while it executes.