Skip to content

Commit 2db556f

Browse files
committed
Prep query system for adding more side effects
1 parent 63a9f90 commit 2db556f

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ macro_rules! define_queries {
871871
is_eval_always: false,
872872
fingerprint_style: FingerprintStyle::Unit,
873873
force_from_dep_node: Some(|tcx, _, prev_index| {
874-
tcx.dep_graph.force_diagnostic_node(QueryCtxt::new(tcx), prev_index);
874+
tcx.dep_graph.force_side_effect_node(QueryCtxt::new(tcx), prev_index);
875875
true
876876
}),
877877
try_load_from_on_disk_cache: None,

compiler/rustc_query_system/src/dep_graph/graph.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -520,21 +520,26 @@ impl<D: Deps> DepGraph<D> {
520520
D::read_deps(|task_deps| match task_deps {
521521
TaskDepsRef::EvalAlways | TaskDepsRef::Ignore => return,
522522
TaskDepsRef::Forbid | TaskDepsRef::Allow(..) => {
523-
self.read_index(data.encode_diagnostic(qcx, diagnostic));
523+
self.read_index(
524+
data.encode_side_effect(
525+
qcx,
526+
QuerySideEffect::Diagnostic(diagnostic.clone()),
527+
),
528+
);
524529
}
525530
})
526531
}
527532
}
528533
/// This forces a diagnostic node green by running its side effect. `prev_index` would
529-
/// refer to a node created used `encode_diagnostic` in the previous session.
534+
/// refer to a node created used [Self::record_diagnostic] in the previous session.
530535
#[inline]
531-
pub fn force_diagnostic_node<Qcx: QueryContext>(
536+
pub fn force_side_effect_node<Qcx: QueryContext>(
532537
&self,
533538
qcx: Qcx,
534539
prev_index: SerializedDepNodeIndex,
535540
) {
536541
if let Some(ref data) = self.data {
537-
data.force_diagnostic_node(qcx, prev_index);
542+
data.force_side_effect_node(qcx, prev_index);
538543
}
539544
}
540545

@@ -665,10 +670,10 @@ impl<D: Deps> DepGraphData<D> {
665670
/// This encodes a diagnostic by creating a node with an unique index and assoicating
666671
/// `diagnostic` with it, for use in the next session.
667672
#[inline]
668-
fn encode_diagnostic<Qcx: QueryContext>(
673+
fn encode_side_effect<Qcx: QueryContext>(
669674
&self,
670675
qcx: Qcx,
671-
diagnostic: &DiagInner,
676+
side_effect: QuerySideEffect,
672677
) -> DepNodeIndex {
673678
// Use `send_new` so we get an unique index, even though the dep node is not.
674679
let dep_node_index = self.current.encoder.send_new(
@@ -677,19 +682,18 @@ impl<D: Deps> DepGraphData<D> {
677682
hash: PackedFingerprint::from(Fingerprint::ZERO),
678683
},
679684
Fingerprint::ZERO,
680-
// We want the side effect node to always be red so it will be forced and emit the
681-
// diagnostic.
685+
// We want the side effect node to always be red so it will be forced and apply
686+
// the side effect
682687
std::iter::once(DepNodeIndex::FOREVER_RED_NODE).collect(),
683688
);
684-
let side_effect = QuerySideEffect::Diagnostic(diagnostic.clone());
685689
qcx.store_side_effect(dep_node_index, side_effect);
686690
dep_node_index
687691
}
688692

689693
/// This forces a diagnostic node green by running its side effect. `prev_index` would
690-
/// refer to a node created used `encode_diagnostic` in the previous session.
694+
/// refer to a node created used [Self::encode_side_effect] in the previous session.
691695
#[inline]
692-
fn force_diagnostic_node<Qcx: QueryContext>(
696+
fn force_side_effect_node<Qcx: QueryContext>(
693697
&self,
694698
qcx: Qcx,
695699
prev_index: SerializedDepNodeIndex,

0 commit comments

Comments
 (0)