1 //! The data that we will serialize and deserialize.
3 use super::{DepKind, DepNode}
;
4 use rustc_data_structures
::fingerprint
::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, Encodable, Decodable)]
13 pub struct SerializedDepGraph
<K
: DepKind
> {
14 /// The set of all DepNodes in the graph
15 pub nodes
: IndexVec
<SerializedDepNodeIndex
, DepNode
<K
>>,
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<K
: DepKind
> Default
for SerializedDepGraph
<K
> {
29 fn default() -> Self {
31 nodes
: Default
::default(),
32 fingerprints
: Default
::default(),
33 edge_list_indices
: Default
::default(),
34 edge_list_data
: Default
::default(),
39 impl<K
: DepKind
> SerializedDepGraph
<K
> {
41 pub fn edge_targets_from(&self, source
: SerializedDepNodeIndex
) -> &[SerializedDepNodeIndex
] {
42 let targets
= self.edge_list_indices
[source
];
43 &self.edge_list_data
[targets
.0 as usize..targets
.1 as usize]