Skip to content

Commit 7cc713e

Browse files
committed
Generate SerializedDepNodeIndex using newtype_index macro
1 parent 583d5a7 commit 7cc713e

File tree

2 files changed

+2
-26
lines changed

2 files changed

+2
-26
lines changed

src/librustc/dep_graph/graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ impl DepGraph {
367367
for (current_dep_node_index, edges) in current_dep_graph.edges.iter_enumerated() {
368368
let start = edge_list_data.len() as u32;
369369
// This should really just be a memcpy :/
370-
edge_list_data.extend(edges.iter().map(|i| SerializedDepNodeIndex(i.index() as u32)));
370+
edge_list_data.extend(edges.iter().map(|i| SerializedDepNodeIndex::new(i.index())));
371371
let end = edge_list_data.len() as u32;
372372

373373
debug_assert_eq!(current_dep_node_index.index(), edge_list_indices.len());

src/librustc/dep_graph/serialized.rs

+1-25
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,7 @@ use dep_graph::DepNode;
1414
use ich::Fingerprint;
1515
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
1616

17-
/// The index of a DepNode in the SerializedDepGraph::nodes array.
18-
#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Debug,
19-
RustcEncodable, RustcDecodable)]
20-
pub struct SerializedDepNodeIndex(pub u32);
21-
22-
impl SerializedDepNodeIndex {
23-
#[inline]
24-
pub fn new(idx: usize) -> SerializedDepNodeIndex {
25-
assert!(idx <= ::std::u32::MAX as usize);
26-
SerializedDepNodeIndex(idx as u32)
27-
}
28-
}
29-
30-
impl Idx for SerializedDepNodeIndex {
31-
#[inline]
32-
fn new(idx: usize) -> Self {
33-
assert!(idx <= ::std::u32::MAX as usize);
34-
SerializedDepNodeIndex(idx as u32)
35-
}
36-
37-
#[inline]
38-
fn index(self) -> usize {
39-
self.0 as usize
40-
}
41-
}
17+
newtype_index!(SerializedDepNodeIndex);
4218

4319
/// Data for use when recompiling the **current crate**.
4420
#[derive(Debug, RustcEncodable, RustcDecodable)]

0 commit comments

Comments
 (0)