diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2017-09-28 16:11:06 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2017-10-04 23:51:43 -0300 |
| commit | 8ee16f4352f3621be75084167185c1f9617859eb (patch) | |
| tree | 247e17574f45f8578724bd9f30623b2b9bf4fb9b | |
| parent | b5a5556dd4807ee97cb51ab395d5dbfc858152dd (diff) | |
| download | rust-8ee16f4352f3621be75084167185c1f9617859eb.tar.gz | |
Generate SerializedDepNodeIndex using newtype_index macro
| -rw-r--r-- | src/librustc/dep_graph/graph.rs | 2 | ||||
| -rw-r--r-- | src/librustc/dep_graph/serialized.rs | 18 |
2 files changed, 2 insertions, 18 deletions
diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 5057b1c6065..cb4126245af 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -406,7 +406,7 @@ impl DepGraph { for (current_dep_node_index, edges) in current_dep_graph.edges.iter_enumerated() { let start = edge_list_data.len() as u32; // This should really just be a memcpy :/ - edge_list_data.extend(edges.iter().map(|i| SerializedDepNodeIndex(i.index() as u32))); + edge_list_data.extend(edges.iter().map(|i| SerializedDepNodeIndex::new(i.index()))); let end = edge_list_data.len() as u32; debug_assert_eq!(current_dep_node_index.index(), edge_list_indices.len()); diff --git a/src/librustc/dep_graph/serialized.rs b/src/librustc/dep_graph/serialized.rs index 7275a740e76..c96040ab9b6 100644 --- a/src/librustc/dep_graph/serialized.rs +++ b/src/librustc/dep_graph/serialized.rs @@ -14,23 +14,7 @@ use dep_graph::DepNode; use ich::Fingerprint; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; -/// The index of a DepNode in the SerializedDepGraph::nodes array. -#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Debug, - RustcEncodable, RustcDecodable)] -pub struct SerializedDepNodeIndex(pub u32); - -impl Idx for SerializedDepNodeIndex { - #[inline] - fn new(idx: usize) -> Self { - assert!(idx <= ::std::u32::MAX as usize); - SerializedDepNodeIndex(idx as u32) - } - - #[inline] - fn index(self) -> usize { - self.0 as usize - } -} +newtype_index!(SerializedDepNodeIndex); /// Data for use when recompiling the **current crate**. #[derive(Debug, RustcEncodable, RustcDecodable)] |
