1111use rustc:: dep_graph:: { DepGraphQuery , DepNode } ;
1212use rustc:: hir:: def_id:: DefId ;
1313use rustc_data_structures:: fx:: FxHashMap ;
14- use rustc_data_structures:: graph:: Graph ;
14+ use rustc_data_structures:: graph:: { Graph , NodeIndex } ;
1515
1616use super :: hash:: * ;
1717use ich:: Fingerprint ;
@@ -28,6 +28,14 @@ pub struct Predecessors<'query> {
2828 // of the graph down.
2929 pub reduced_graph : Graph < & ' query DepNode < DefId > , ( ) > ,
3030
31+ // These are output nodes that have no incoming edges. We have to
32+ // track these specially because, when we load the data back up
33+ // again, we want to make sure and recreate these nodes (we want
34+ // to recreate the nodes where all incoming edges are clean; but
35+ // since we ordinarily just serialize edges, we wind up just
36+ // forgetting that bootstrap outputs even exist in that case.)
37+ pub bootstrap_outputs : Vec < & ' query DepNode < DefId > > ,
38+
3139 // For the inputs (hir/foreign-metadata), we include hashes.
3240 pub hashes : FxHashMap < & ' query DepNode < DefId > , Fingerprint > ,
3341}
@@ -57,7 +65,7 @@ impl<'q> Predecessors<'q> {
5765
5866 // Reduce the graph to the most important nodes.
5967 let compress:: Reduction { graph, input_nodes } =
60- compress:: reduce_graph ( & query. graph , HashContext :: is_hashable, is_output) ;
68+ compress:: reduce_graph ( & query. graph , HashContext :: is_hashable, |n| is_output ( n ) ) ;
6169
6270 let mut hashes = FxHashMap ( ) ;
6371 for input_index in input_nodes {
@@ -67,8 +75,17 @@ impl<'q> Predecessors<'q> {
6775 . or_insert_with ( || hcx. hash ( input) . unwrap ( ) ) ;
6876 }
6977
78+ let bootstrap_outputs: Vec < & ' q DepNode < DefId > > =
79+ ( 0 .. graph. len_nodes ( ) )
80+ . map ( NodeIndex )
81+ . filter ( |& n| graph. incoming_edges ( n) . next ( ) . is_none ( ) )
82+ . map ( |n| * graph. node_data ( n) )
83+ . filter ( |n| is_output ( n) )
84+ . collect ( ) ;
85+
7086 Predecessors {
7187 reduced_graph : graph,
88+ bootstrap_outputs : bootstrap_outputs,
7289 hashes : hashes,
7390 }
7491 }
0 commit comments