11
11
use rustc:: dep_graph:: { DepGraphQuery , DepNode } ;
12
12
use rustc:: hir:: def_id:: DefId ;
13
13
use rustc_data_structures:: fx:: FxHashMap ;
14
- use rustc_data_structures:: graph:: Graph ;
14
+ use rustc_data_structures:: graph:: { Graph , NodeIndex } ;
15
15
16
16
use super :: hash:: * ;
17
17
use ich:: Fingerprint ;
@@ -28,6 +28,14 @@ pub struct Predecessors<'query> {
28
28
// of the graph down.
29
29
pub reduced_graph : Graph < & ' query DepNode < DefId > , ( ) > ,
30
30
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
+
31
39
// For the inputs (hir/foreign-metadata), we include hashes.
32
40
pub hashes : FxHashMap < & ' query DepNode < DefId > , Fingerprint > ,
33
41
}
@@ -57,7 +65,7 @@ impl<'q> Predecessors<'q> {
57
65
58
66
// Reduce the graph to the most important nodes.
59
67
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 ) ) ;
61
69
62
70
let mut hashes = FxHashMap ( ) ;
63
71
for input_index in input_nodes {
@@ -67,8 +75,17 @@ impl<'q> Predecessors<'q> {
67
75
. or_insert_with ( || hcx. hash ( input) . unwrap ( ) ) ;
68
76
}
69
77
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
+
70
86
Predecessors {
71
87
reduced_graph : graph,
88
+ bootstrap_outputs : bootstrap_outputs,
72
89
hashes : hashes,
73
90
}
74
91
}
0 commit comments