Skip to content

Commit 927ad16

Browse files
committed
Add a dep kind for use of the anon node with zero dependencies
1 parent 70dab5a commit 927ad16

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

Diff for: compiler/rustc_middle/src/dep_graph/dep_node.rs

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ rustc_query_append!(define_dep_nodes![
8989
/// We use this to create a forever-red node.
9090
[] fn Red() -> (),
9191
[] fn SideEffect() -> (),
92+
[] fn AnonZeroDeps() -> (),
9293
[] fn TraitSelect() -> (),
9394
[] fn CompileCodegenUnit() -> (),
9495
[] fn CompileMonoItem() -> (),

Diff for: compiler/rustc_middle/src/dep_graph/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ impl Deps for DepsType {
5353
const DEP_KIND_NULL: DepKind = dep_kinds::Null;
5454
const DEP_KIND_RED: DepKind = dep_kinds::Red;
5555
const DEP_KIND_SIDE_EFFECT: DepKind = dep_kinds::SideEffect;
56+
const DEP_KIND_ANON_ZERO_DEPS: DepKind = dep_kinds::AnonZeroDeps;
5657
const DEP_KIND_MAX: u16 = dep_node::DEP_KIND_VARIANTS - 1;
5758
}
5859

Diff for: compiler/rustc_query_impl/src/plumbing.rs

+11
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,17 @@ macro_rules! define_queries {
870870
}
871871
}
872872

873+
pub(crate) fn AnonZeroDeps<'tcx>() -> DepKindStruct<'tcx> {
874+
DepKindStruct {
875+
is_anon: true,
876+
is_eval_always: false,
877+
fingerprint_style: FingerprintStyle::Opaque,
878+
force_from_dep_node: Some(|_, _, _| bug!("cannot force an anon node")),
879+
try_load_from_on_disk_cache: None,
880+
name: &"AnonZeroDeps",
881+
}
882+
}
883+
873884
pub(crate) fn TraitSelect<'tcx>() -> DepKindStruct<'tcx> {
874885
DepKindStruct {
875886
is_anon: true,

Diff for: compiler/rustc_query_system/src/dep_graph/graph.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ rustc_index::newtype_index! {
5050
rustc_data_structures::static_assert_size!(Option<DepNodeIndex>, 4);
5151

5252
impl DepNodeIndex {
53-
const SINGLETON_DEPENDENCYLESS_ANON_NODE: DepNodeIndex = DepNodeIndex::ZERO;
53+
const SINGLETON_ZERO_DEPS_ANON_NODE: DepNodeIndex = DepNodeIndex::ZERO;
5454
pub const FOREVER_RED_NODE: DepNodeIndex = DepNodeIndex::from_u32(1);
5555
}
5656

@@ -140,13 +140,13 @@ impl<D: Deps> DepGraph<D> {
140140

141141
let colors = DepNodeColorMap::new(prev_graph_node_count);
142142

143-
// Instantiate a dependy-less node only once for anonymous queries.
143+
// Instantiate a node with zero dependencies only once for anonymous queries.
144144
let _green_node_index = current.alloc_node(
145-
DepNode { kind: D::DEP_KIND_NULL, hash: current.anon_id_seed.into() },
145+
DepNode { kind: D::DEP_KIND_ANON_ZERO_DEPS, hash: current.anon_id_seed.into() },
146146
EdgesVec::new(),
147147
Fingerprint::ZERO,
148148
);
149-
assert_eq!(_green_node_index, DepNodeIndex::SINGLETON_DEPENDENCYLESS_ANON_NODE);
149+
assert_eq!(_green_node_index, DepNodeIndex::SINGLETON_ZERO_DEPS_ANON_NODE);
150150

151151
// Instantiate a dependy-less red node only once for anonymous queries.
152152
let red_node_index = current.alloc_node(
@@ -407,7 +407,7 @@ impl<D: Deps> DepGraphData<D> {
407407
// going to be (i.e. equal to the precomputed
408408
// `SINGLETON_DEPENDENCYLESS_ANON_NODE`). As a consequence we can skip creating
409409
// a `StableHasher` and sending the node through interning.
410-
DepNodeIndex::SINGLETON_DEPENDENCYLESS_ANON_NODE
410+
DepNodeIndex::SINGLETON_ZERO_DEPS_ANON_NODE
411411
}
412412
1 => {
413413
// When there is only one dependency, don't bother creating a node.

Diff for: compiler/rustc_query_system/src/dep_graph/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ pub trait Deps {
111111
/// We use this to create a side effect node.
112112
const DEP_KIND_SIDE_EFFECT: DepKind;
113113

114+
/// We use this to create the anon node with zero dependencies.
115+
const DEP_KIND_ANON_ZERO_DEPS: DepKind;
116+
114117
/// This is the highest value a `DepKind` can have. It's used during encoding to
115118
/// pack information into the unused bits.
116119
const DEP_KIND_MAX: u16;

0 commit comments

Comments
 (0)