@@ -44,7 +44,7 @@ rustc_index::newtype_index! {
4444
4545impl 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
5050impl 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