]> git.lizzy.rs Git - rust.git/blob - src/librustc/dep_graph/serialized.rs
Rollup merge of #61698 - davidtwco:ice-const-generic-length, r=varkor
[rust.git] / src / librustc / dep_graph / serialized.rs
1 //! The data that we will serialize and deserialize.
2
3 use crate::dep_graph::DepNode;
4 use crate::ich::Fingerprint;
5 use rustc_data_structures::indexed_vec::{IndexVec, Idx};
6
7 newtype_index! {
8     pub struct SerializedDepNodeIndex { .. }
9 }
10
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>,
26 }
27
28 impl SerializedDepGraph {
29     #[inline]
30     pub fn edge_targets_from(&self,
31                              source: SerializedDepNodeIndex)
32                              -> &[SerializedDepNodeIndex] {
33         let targets = self.edge_list_indices[source];
34         &self.edge_list_data[targets.0 as usize..targets.1 as usize]
35     }
36 }