Skip to content

Commit b51f24f

Browse files
committed
Make the reasoning more explicit.
1 parent 3a6d5c2 commit b51f24f

File tree

1 file changed

+9
-5
lines changed
  • compiler/rustc_query_system/src/dep_graph

1 file changed

+9
-5
lines changed

compiler/rustc_query_system/src/dep_graph/graph.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ rustc_index::newtype_index! {
4444

4545
impl DepNodeIndex {
4646
pub const INVALID: DepNodeIndex = DepNodeIndex::MAX;
47-
pub const DUMMY_ANON: DepNodeIndex = DepNodeIndex::from_u32(0);
47+
pub const SINGLETON_DEPENDENCYLESS_ANON_NODE: DepNodeIndex = DepNodeIndex::from_u32(0);
4848
}
4949

5050
impl std::convert::From<DepNodeIndex> for QueryInvocationId {
@@ -121,14 +121,14 @@ impl<K: DepKind> DepGraph<K> {
121121
let current =
122122
CurrentDepGraph::new(prev_graph_node_count, encoder, record_graph, record_stats);
123123

124-
// Instantiate an *always green* node for dependency-less anonymous queries.
124+
// Instantiate a dependy-less node only once for anonymous queries.
125125
let _green_node_index = current.intern_new_node(
126126
profiler,
127127
DepNode { kind: DepKind::NULL, hash: current.anon_id_seed.into() },
128128
smallvec![],
129129
Fingerprint::ZERO,
130130
);
131-
debug_assert_eq!(_green_node_index, DepNodeIndex::DUMMY_ANON);
131+
debug_assert_eq!(_green_node_index, DepNodeIndex::SINGLETON_DEPENDENCYLESS_ANON_NODE);
132132

133133
DepGraph {
134134
data: Some(Lrc::new(DepGraphData {
@@ -300,8 +300,12 @@ impl<K: DepKind> DepGraph<K> {
300300

301301
let dep_node_index = match task_deps.len() {
302302
0 => {
303-
// Dependency-less anonymous nodes can safely be replaced by a dummy node.
304-
DepNodeIndex::DUMMY_ANON
303+
// Because the dep-node id of anon nodes is computed from the sets of its
304+
// dependencies we already know what the ID of this dependency-less node is
305+
// going to be (i.e. equal to the precomputed
306+
// `SINGLETON_DEPENDENCYLESS_ANON_NODE`). As a consequence we can skip creating
307+
// a `StableHasher` and sending the node through interning.
308+
DepNodeIndex::SINGLETON_DEPENDENCYLESS_ANON_NODE
305309
}
306310
1 => {
307311
// When there is only one dependency, don't bother creating a node.

0 commit comments

Comments
 (0)