1 //! The data that we will serialize and deserialize.
3 use crate::dep_graph::DepNode;
4 use crate::ich::Fingerprint;
5 use rustc_index::vec::IndexVec;
7 rustc_index::newtype_index! {
8 pub struct SerializedDepNodeIndex { .. }
11 /// Data for use when recompiling the **current crate**.
12 #[derive(Debug, RustcEncodable, RustcDecodable, Default)]
13 pub struct SerializedDepGraph {
14 /// The set of all DepNodes in the graph
15 pub nodes: IndexVec<SerializedDepNodeIndex, DepNode>,
16 /// The set of all Fingerprints in the graph. Each Fingerprint corresponds to
17 /// the DepNode at the same index in the nodes vector.
18 pub fingerprints: IndexVec<SerializedDepNodeIndex, Fingerprint>,
19 /// For each DepNode, stores the list of edges originating from that
20 /// DepNode. Encoded as a [start, end) pair indexing into edge_list_data,
21 /// which holds the actual DepNodeIndices of the target nodes.
22 pub edge_list_indices: IndexVec<SerializedDepNodeIndex, (u32, u32)>,
23 /// A flattened list of all edge targets in the graph. Edge sources are
24 /// implicit in edge_list_indices.
25 pub edge_list_data: Vec<SerializedDepNodeIndex>,
28 impl SerializedDepGraph {
30 pub fn edge_targets_from(&self, source: SerializedDepNodeIndex) -> &[SerializedDepNodeIndex] {
31 let targets = self.edge_list_indices[source];
32 &self.edge_list_data[targets.0 as usize..targets.1 as usize]