@@ -349,7 +349,7 @@ impl<K: DepKind> DepGraphData<K> {
349
349
// in `DepGraph::try_mark_green()`.
350
350
// 2. Two distinct query keys get mapped to the same `DepNode`
351
351
// (see for example #48923).
352
- self . assert_nonexistent_node ( & key, || {
352
+ self . assert_dep_node_not_yet_allocated_in_current_session ( & key, || {
353
353
format ! (
354
354
"forcing query with already existing `DepNode`\n \
355
355
- query-key: {arg:?}\n \
@@ -647,14 +647,19 @@ impl<K: DepKind> DepGraph<K> {
647
647
}
648
648
649
649
impl < K : DepKind > DepGraphData < K > {
650
- fn assert_nonexistent_node < S : std:: fmt:: Display > (
650
+ fn assert_dep_node_not_yet_allocated_in_current_session < S : std:: fmt:: Display > (
651
651
& self ,
652
652
_dep_node : & DepNode < K > ,
653
653
_msg : impl FnOnce ( ) -> S ,
654
654
) {
655
655
#[ cfg( debug_assertions) ]
656
- if let Some ( seen_dep_nodes) = & self . current . seen_dep_nodes {
657
- let seen = seen_dep_nodes. lock ( ) . contains ( _dep_node) ;
656
+ if let Some ( prev_index) = self . previous . node_to_index_opt ( _dep_node) {
657
+ let current = self . current . prev_index_to_index . lock ( ) [ prev_index] ;
658
+ assert ! ( current. is_none( ) , "{}" , _msg( ) )
659
+ } else if let Some ( nodes_newly_allocated_in_current_session) =
660
+ & self . current . nodes_newly_allocated_in_current_session
661
+ {
662
+ let seen = nodes_newly_allocated_in_current_session. lock ( ) . contains ( _dep_node) ;
658
663
assert ! ( !seen, "{}" , _msg( ) ) ;
659
664
}
660
665
}
@@ -871,7 +876,7 @@ impl<K: DepKind> DepGraphData<K> {
871
876
let frame = MarkFrame { index : prev_dep_node_index, parent : frame } ;
872
877
873
878
#[ cfg( not( parallel_compiler) ) ]
874
- self . assert_nonexistent_node ( dep_node, || {
879
+ self . assert_dep_node_not_yet_allocated_in_current_session ( dep_node, || {
875
880
format ! ( "trying to mark existing {dep_node:?} as green" )
876
881
} ) ;
877
882
#[ cfg( not( parallel_compiler) ) ]
@@ -970,15 +975,15 @@ impl<K: DepKind> DepGraph<K> {
970
975
self . node_color ( dep_node) . is_some_and ( |c| c. is_green ( ) )
971
976
}
972
977
973
- pub fn assert_nonexistent_node < S : std:: fmt:: Display > (
978
+ pub fn assert_dep_node_not_yet_allocated_in_current_session < S : std:: fmt:: Display > (
974
979
& self ,
975
980
dep_node : & DepNode < K > ,
976
981
msg : impl FnOnce ( ) -> S ,
977
982
) {
978
983
if cfg ! ( debug_assertions)
979
984
&& let Some ( data) = & self . data
980
985
{
981
- data. assert_nonexistent_node ( dep_node, msg)
986
+ data. assert_dep_node_not_yet_allocated_in_current_session ( dep_node, msg)
982
987
}
983
988
}
984
989
@@ -1120,8 +1125,11 @@ pub(super) struct CurrentDepGraph<K: DepKind> {
1120
1125
1121
1126
/// Used to verify the absence of hash collisions among DepNodes.
1122
1127
/// This field is only `Some` if the `-Z incremental_verify_ich` option is present.
1128
+ ///
1129
+ /// The map contains all DepNodes that have been allocated in the current session so far and
1130
+ /// for which there is no equivalent in the previous session.
1123
1131
#[ cfg( debug_assertions) ]
1124
- seen_dep_nodes : Option < Lock < FxHashSet < DepNode < K > > > > ,
1132
+ nodes_newly_allocated_in_current_session : Option < Lock < FxHashSet < DepNode < K > > > > ,
1125
1133
1126
1134
/// Anonymous `DepNode`s are nodes whose IDs we compute from the list of
1127
1135
/// their edges. This has the beneficial side-effect that multiple anonymous
@@ -1205,12 +1213,16 @@ impl<K: DepKind> CurrentDepGraph<K> {
1205
1213
#[ cfg( debug_assertions) ]
1206
1214
fingerprints : Lock :: new ( IndexVec :: from_elem_n ( None , new_node_count_estimate) ) ,
1207
1215
#[ cfg( debug_assertions) ]
1208
- seen_dep_nodes : session. opts . unstable_opts . incremental_verify_ich . then ( || {
1209
- Lock :: new ( FxHashSet :: with_capacity_and_hasher (
1210
- new_node_count_estimate,
1211
- Default :: default ( ) ,
1212
- ) )
1213
- } ) ,
1216
+ nodes_newly_allocated_in_current_session : session
1217
+ . opts
1218
+ . unstable_opts
1219
+ . incremental_verify_ich
1220
+ . then ( || {
1221
+ Lock :: new ( FxHashSet :: with_capacity_and_hasher (
1222
+ new_node_count_estimate,
1223
+ Default :: default ( ) ,
1224
+ ) )
1225
+ } ) ,
1214
1226
total_read_count : AtomicU64 :: new ( 0 ) ,
1215
1227
total_duplicate_read_count : AtomicU64 :: new ( 0 ) ,
1216
1228
node_intern_event_id,
@@ -1242,8 +1254,10 @@ impl<K: DepKind> CurrentDepGraph<K> {
1242
1254
self . record_edge ( dep_node_index, key, current_fingerprint) ;
1243
1255
1244
1256
#[ cfg( debug_assertions) ]
1245
- if let Some ( ref seen_dep_nodes) = self . seen_dep_nodes {
1246
- if !seen_dep_nodes. lock ( ) . insert ( key) {
1257
+ if let Some ( ref nodes_newly_allocated_in_current_session) =
1258
+ self . nodes_newly_allocated_in_current_session
1259
+ {
1260
+ if !nodes_newly_allocated_in_current_session. lock ( ) . insert ( key) {
1247
1261
panic ! ( "Found duplicate dep-node {key:?}" ) ;
1248
1262
}
1249
1263
}
0 commit comments