Skip to content

Commit 8ee16f4

Browse files
committed
Generate SerializedDepNodeIndex using newtype_index macro
1 parent b5a5556 commit 8ee16f4

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

src/librustc/dep_graph/graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ impl DepGraph {
406406
for (current_dep_node_index, edges) in current_dep_graph.edges.iter_enumerated() {
407407
let start = edge_list_data.len() as u32;
408408
// This should really just be a memcpy :/
409-
edge_list_data.extend(edges.iter().map(|i| SerializedDepNodeIndex(i.index() as u32)));
409+
edge_list_data.extend(edges.iter().map(|i| SerializedDepNodeIndex::new(i.index())));
410410
let end = edge_list_data.len() as u32;
411411

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

src/librustc/dep_graph/serialized.rs

+1-17
Original file line numberDiff line numberDiff line change
@@ -14,23 +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 Idx for SerializedDepNodeIndex {
23-
#[inline]
24-
fn new(idx: usize) -> Self {
25-
assert!(idx <= ::std::u32::MAX as usize);
26-
SerializedDepNodeIndex(idx as u32)
27-
}
28-
29-
#[inline]
30-
fn index(self) -> usize {
31-
self.0 as usize
32-
}
33-
}
17+
newtype_index!(SerializedDepNodeIndex);
3418

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

0 commit comments

Comments
 (0)