@@ -653,7 +653,7 @@ impl<D: Deps> DepGraphData<D> {
653
653
& self . current . nodes_newly_allocated_in_current_session
654
654
{
655
655
outline ( || {
656
- let seen = nodes_newly_allocated_in_current_session. lock ( ) . contains ( dep_node) ;
656
+ let seen = nodes_newly_allocated_in_current_session. lock ( ) . contains_key ( dep_node) ;
657
657
assert ! ( !seen, "{}" , msg( ) ) ;
658
658
} ) ;
659
659
}
@@ -1103,7 +1103,7 @@ pub(super) struct CurrentDepGraph<D: Deps> {
1103
1103
///
1104
1104
/// The map contains all DepNodes that have been allocated in the current session so far and
1105
1105
/// for which there is no equivalent in the previous session.
1106
- nodes_newly_allocated_in_current_session : Option < Lock < FxHashSet < DepNode > > > ,
1106
+ nodes_newly_allocated_in_current_session : Option < Lock < FxHashMap < DepNode , DepNodeIndex > > > ,
1107
1107
1108
1108
/// Anonymous `DepNode`s are nodes whose IDs we compute from the list of
1109
1109
/// their edges. This has the beneficial side-effect that multiple anonymous
@@ -1178,7 +1178,7 @@ impl<D: Deps> CurrentDepGraph<D> {
1178
1178
#[ cfg( debug_assertions) ]
1179
1179
fingerprints : Lock :: new ( IndexVec :: from_elem_n ( None , new_node_count_estimate) ) ,
1180
1180
nodes_newly_allocated_in_current_session : new_node_dbg. then ( || {
1181
- Lock :: new ( FxHashSet :: with_capacity_and_hasher (
1181
+ Lock :: new ( FxHashMap :: with_capacity_and_hasher (
1182
1182
new_node_count_estimate,
1183
1183
Default :: default ( ) ,
1184
1184
) )
@@ -1215,7 +1215,11 @@ impl<D: Deps> CurrentDepGraph<D> {
1215
1215
self . nodes_newly_allocated_in_current_session
1216
1216
{
1217
1217
outline ( || {
1218
- if !nodes_newly_allocated_in_current_session. lock ( ) . insert ( key) {
1218
+ if nodes_newly_allocated_in_current_session
1219
+ . lock ( )
1220
+ . insert ( key, dep_node_index)
1221
+ . is_some ( )
1222
+ {
1219
1223
panic ! ( "Found duplicate dep-node {key:?}" ) ;
1220
1224
}
1221
1225
} ) ;
@@ -1317,7 +1321,7 @@ impl<D: Deps> CurrentDepGraph<D> {
1317
1321
!self
1318
1322
. nodes_newly_allocated_in_current_session
1319
1323
. as_ref( )
1320
- . map_or( false , |set| set. lock( ) . contains ( node) ) ,
1324
+ . map_or( false , |set| set. lock( ) . contains_key ( node) ) ,
1321
1325
"node from previous graph present in new node collection"
1322
1326
) ;
1323
1327
}
@@ -1439,6 +1443,15 @@ fn panic_on_forbidden_read<D: Deps>(data: &DepGraphData<D>, dep_node_index: DepN
1439
1443
}
1440
1444
}
1441
1445
1446
+ if dep_node. is_none ( )
1447
+ && let Some ( nodes) = & data. current . nodes_newly_allocated_in_current_session
1448
+ {
1449
+ // Try to find it among the nodes allocated so far in this session
1450
+ if let Some ( ( node, _) ) = nodes. lock ( ) . iter ( ) . find ( |& ( _, index) | * index == dep_node_index) {
1451
+ dep_node = Some ( * node) ;
1452
+ }
1453
+ }
1454
+
1442
1455
let dep_node = dep_node. map_or_else (
1443
1456
|| format ! ( "with index {:?}" , dep_node_index) ,
1444
1457
|dep_node| format ! ( "`{:?}`" , dep_node) ,
0 commit comments