File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
compiler/rustc_query_system/src/dep_graph Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -252,8 +252,27 @@ impl SerializedDepGraph {
252252 . map ( |_| UnhashMap :: with_capacity_and_hasher ( d. read_u32 ( ) as usize , Default :: default ( ) ) )
253253 . collect ( ) ;
254254
255+ let mut duplicates = Vec :: new ( ) ;
255256 for ( idx, node) in nodes. iter_enumerated ( ) {
256- index[ node. kind . as_usize ( ) ] . insert ( node. hash , idx) ;
257+ if index[ node. kind . as_usize ( ) ] . insert ( node. hash , idx) . is_some ( ) {
258+ duplicates. push ( node) ;
259+ }
260+ }
261+
262+ // Creating the index detected a duplicated DepNode.
263+ //
264+ // If the new session presents us with a DepNode among those, we have no
265+ // way to know which SerializedDepNodeIndex it corresponds to. To avoid
266+ // making the wrong connection between a DepNodeIndex and a SerializedDepNodeIndex,
267+ // we remove all the duplicates from the index.
268+ //
269+ // This way, when the new session presents us with a DepNode among the duplicates,
270+ // we just create a new node with no counterpart in the previous graph.
271+ //
272+ // Red/green marking still works for those nodes, as that algorithm does not
273+ // need to know about DepNode at all.
274+ for node in duplicates {
275+ index[ node. kind . as_usize ( ) ] . remove ( & node. hash ) ;
257276 }
258277
259278 Arc :: new ( SerializedDepGraph {
You can’t perform that action at this time.
0 commit comments