@@ -677,7 +677,7 @@ impl<D: Deps> DepGraphData<D> {
677677 & self . current . nodes_newly_allocated_in_current_session
678678 {
679679 outline ( || {
680- let seen = nodes_newly_allocated_in_current_session. lock ( ) . contains ( dep_node) ;
680+ let seen = nodes_newly_allocated_in_current_session. lock ( ) . contains_key ( dep_node) ;
681681 assert ! ( !seen, "{}" , msg( ) ) ;
682682 } ) ;
683683 }
@@ -1141,7 +1141,7 @@ pub(super) struct CurrentDepGraph<D: Deps> {
11411141 ///
11421142 /// The map contains all DepNodes that have been allocated in the current session so far and
11431143 /// for which there is no equivalent in the previous session.
1144- nodes_newly_allocated_in_current_session : Option < Lock < FxHashSet < DepNode > > > ,
1144+ nodes_newly_allocated_in_current_session : Option < Lock < FxHashMap < DepNode , DepNodeIndex > > > ,
11451145
11461146 /// Anonymous `DepNode`s are nodes whose IDs we compute from the list of
11471147 /// their edges. This has the beneficial side-effect that multiple anonymous
@@ -1216,7 +1216,7 @@ impl<D: Deps> CurrentDepGraph<D> {
12161216 #[ cfg( debug_assertions) ]
12171217 fingerprints : Lock :: new ( IndexVec :: from_elem_n ( None , new_node_count_estimate) ) ,
12181218 nodes_newly_allocated_in_current_session : new_node_dbg. then ( || {
1219- Lock :: new ( FxHashSet :: with_capacity_and_hasher (
1219+ Lock :: new ( FxHashMap :: with_capacity_and_hasher (
12201220 new_node_count_estimate,
12211221 Default :: default ( ) ,
12221222 ) )
@@ -1253,7 +1253,11 @@ impl<D: Deps> CurrentDepGraph<D> {
12531253 self . nodes_newly_allocated_in_current_session
12541254 {
12551255 outline ( || {
1256- if !nodes_newly_allocated_in_current_session. lock ( ) . insert ( key) {
1256+ if nodes_newly_allocated_in_current_session
1257+ . lock ( )
1258+ . insert ( key, dep_node_index)
1259+ . is_some ( )
1260+ {
12571261 panic ! ( "Found duplicate dep-node {key:?}" ) ;
12581262 }
12591263 } ) ;
@@ -1355,7 +1359,7 @@ impl<D: Deps> CurrentDepGraph<D> {
13551359 !self
13561360 . nodes_newly_allocated_in_current_session
13571361 . as_ref( )
1358- . map_or( false , |set| set. lock( ) . contains ( node) ) ,
1362+ . map_or( false , |set| set. lock( ) . contains_key ( node) ) ,
13591363 "node from previous graph present in new node collection"
13601364 ) ;
13611365 }
@@ -1477,6 +1481,15 @@ fn panic_on_forbidden_read<D: Deps>(data: &DepGraphData<D>, dep_node_index: DepN
14771481 }
14781482 }
14791483
1484+ if dep_node. is_none ( )
1485+ && let Some ( nodes) = & data. current . nodes_newly_allocated_in_current_session
1486+ {
1487+ // Try to find it among the nodes allocated so far in this session
1488+ if let Some ( ( node, _) ) = nodes. lock ( ) . iter ( ) . find ( |& ( _, index) | * index == dep_node_index) {
1489+ dep_node = Some ( * node) ;
1490+ }
1491+ }
1492+
14801493 let dep_node = dep_node. map_or_else (
14811494 || format ! ( "with index {:?}" , dep_node_index) ,
14821495 |dep_node| format ! ( "`{:?}`" , dep_node) ,
0 commit comments