@@ -44,7 +44,7 @@ rustc_index::newtype_index! {
44
44
45
45
impl DepNodeIndex {
46
46
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 ) ;
48
48
}
49
49
50
50
impl std:: convert:: From < DepNodeIndex > for QueryInvocationId {
@@ -121,14 +121,14 @@ impl<K: DepKind> DepGraph<K> {
121
121
let current =
122
122
CurrentDepGraph :: new ( prev_graph_node_count, encoder, record_graph, record_stats) ;
123
123
124
- // Instantiate an *always green* node for dependency-less anonymous queries.
124
+ // Instantiate a dependy-less node only once for anonymous queries.
125
125
let _green_node_index = current. intern_new_node (
126
126
profiler,
127
127
DepNode { kind : DepKind :: NULL , hash : current. anon_id_seed . into ( ) } ,
128
128
smallvec ! [ ] ,
129
129
Fingerprint :: ZERO ,
130
130
) ;
131
- debug_assert_eq ! ( _green_node_index, DepNodeIndex :: DUMMY_ANON ) ;
131
+ debug_assert_eq ! ( _green_node_index, DepNodeIndex :: SINGLETON_DEPENDENCYLESS_ANON_NODE ) ;
132
132
133
133
DepGraph {
134
134
data : Some ( Lrc :: new ( DepGraphData {
@@ -300,8 +300,12 @@ impl<K: DepKind> DepGraph<K> {
300
300
301
301
let dep_node_index = match task_deps. len ( ) {
302
302
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
305
309
}
306
310
1 => {
307
311
// When there is only one dependency, don't bother creating a node.
0 commit comments