@@ -653,7 +653,7 @@ impl<D: Deps> DepGraphData<D> {
653653 & self . current . nodes_newly_allocated_in_current_session
654654 {
655655 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) ;
657657 assert ! ( !seen, "{}" , msg( ) ) ;
658658 } ) ;
659659 }
@@ -1103,7 +1103,7 @@ pub(super) struct CurrentDepGraph<D: Deps> {
11031103 ///
11041104 /// The map contains all DepNodes that have been allocated in the current session so far and
11051105 /// 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 > > > ,
11071107
11081108 /// Anonymous `DepNode`s are nodes whose IDs we compute from the list of
11091109 /// their edges. This has the beneficial side-effect that multiple anonymous
@@ -1178,7 +1178,7 @@ impl<D: Deps> CurrentDepGraph<D> {
11781178 #[ cfg( debug_assertions) ]
11791179 fingerprints : Lock :: new ( IndexVec :: from_elem_n ( None , new_node_count_estimate) ) ,
11801180 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 (
11821182 new_node_count_estimate,
11831183 Default :: default ( ) ,
11841184 ) )
@@ -1215,7 +1215,11 @@ impl<D: Deps> CurrentDepGraph<D> {
12151215 self . nodes_newly_allocated_in_current_session
12161216 {
12171217 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+ {
12191223 panic ! ( "Found duplicate dep-node {key:?}" ) ;
12201224 }
12211225 } ) ;
@@ -1317,7 +1321,7 @@ impl<D: Deps> CurrentDepGraph<D> {
13171321 !self
13181322 . nodes_newly_allocated_in_current_session
13191323 . as_ref( )
1320- . map_or( false , |set| set. lock( ) . contains ( node) ) ,
1324+ . map_or( false , |set| set. lock( ) . contains_key ( node) ) ,
13211325 "node from previous graph present in new node collection"
13221326 ) ;
13231327 }
@@ -1439,6 +1443,15 @@ fn panic_on_forbidden_read<D: Deps>(data: &DepGraphData<D>, dep_node_index: DepN
14391443 }
14401444 }
14411445
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+
14421455 let dep_node = dep_node. map_or_else (
14431456 || format ! ( "with index {:?}" , dep_node_index) ,
14441457 |dep_node| format ! ( "`{:?}`" , dep_node) ,
0 commit comments