@@ -43,6 +43,7 @@ rustc_index::newtype_index! {
43
43
impl DepNodeIndex {
44
44
pub const INVALID : DepNodeIndex = DepNodeIndex :: MAX ;
45
45
pub const SINGLETON_DEPENDENCYLESS_ANON_NODE : DepNodeIndex = DepNodeIndex :: from_u32 ( 0 ) ;
46
+ pub const FOREVER_RED_NODE : DepNodeIndex = DepNodeIndex :: from_u32 ( 1 ) ;
46
47
}
47
48
48
49
impl std:: convert:: From < DepNodeIndex > for QueryInvocationId {
@@ -124,6 +125,8 @@ impl<K: DepKind> DepGraph<K> {
124
125
record_stats,
125
126
) ;
126
127
128
+ let colors = DepNodeColorMap :: new ( prev_graph_node_count) ;
129
+
127
130
// Instantiate a dependy-less node only once for anonymous queries.
128
131
let _green_node_index = current. intern_new_node (
129
132
profiler,
@@ -133,14 +136,26 @@ impl<K: DepKind> DepGraph<K> {
133
136
) ;
134
137
debug_assert_eq ! ( _green_node_index, DepNodeIndex :: SINGLETON_DEPENDENCYLESS_ANON_NODE ) ;
135
138
139
+ // Instantiate a dependy-less red node only once for anonymous queries.
140
+ let ( _red_node_index, _prev_and_index) = current. intern_node (
141
+ profiler,
142
+ & prev_graph,
143
+ DepNode { kind : DepKind :: NULL , hash : Fingerprint :: ZERO . into ( ) } ,
144
+ smallvec ! [ ] ,
145
+ None ,
146
+ false ,
147
+ ) ;
148
+ debug_assert_eq ! ( _red_node_index, DepNodeIndex :: FOREVER_RED_NODE ) ;
149
+ debug_assert ! ( matches!( _prev_and_index, None | Some ( ( _, DepNodeColor :: Red ) ) ) ) ;
150
+
136
151
DepGraph {
137
152
data : Some ( Lrc :: new ( DepGraphData {
138
153
previous_work_products : prev_work_products,
139
154
dep_node_debug : Default :: default ( ) ,
140
155
current,
141
156
processed_side_effects : Default :: default ( ) ,
142
157
previous : prev_graph,
143
- colors : DepNodeColorMap :: new ( prev_graph_node_count ) ,
158
+ colors,
144
159
debug_loaded_from_disk : Default :: default ( ) ,
145
160
} ) ) ,
146
161
virtual_dep_node_index : Lrc :: new ( AtomicU32 :: new ( 0 ) ) ,
@@ -965,6 +980,9 @@ impl<K: DepKind> CurrentDepGraph<K> {
965
980
let nanos = duration. as_secs ( ) * 1_000_000_000 + duration. subsec_nanos ( ) as u64 ;
966
981
let mut stable_hasher = StableHasher :: new ( ) ;
967
982
nanos. hash ( & mut stable_hasher) ;
983
+ let anon_id_seed = stable_hasher. finish ( ) ;
984
+ // We rely on the fact that `anon_id_seed` is not zero when creating static nodes.
985
+ debug_assert_ne ! ( anon_id_seed, Fingerprint :: ZERO ) ;
968
986
969
987
#[ cfg( debug_assertions) ]
970
988
let forbidden_edge = match env:: var ( "RUST_FORBID_DEP_GRAPH_EDGE" ) {
@@ -1000,7 +1018,7 @@ impl<K: DepKind> CurrentDepGraph<K> {
1000
1018
)
1001
1019
} ) ,
1002
1020
prev_index_to_index : Lock :: new ( IndexVec :: from_elem_n ( None , prev_graph_node_count) ) ,
1003
- anon_id_seed : stable_hasher . finish ( ) ,
1021
+ anon_id_seed,
1004
1022
#[ cfg( debug_assertions) ]
1005
1023
forbidden_edge,
1006
1024
total_read_count : AtomicU64 :: new ( 0 ) ,
0 commit comments