Skip to content

Commit 224e87f

Browse files
committed
Generate DepNodeIndex using newtype_index macro
1 parent fdbb346 commit 224e87f

File tree

3 files changed

+5
-27
lines changed

3 files changed

+5
-27
lines changed

src/librustc_incremental/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
html_root_url = "https://doc.rust-lang.org/nightly/")]
1616
#![deny(warnings)]
1717

18+
#![feature(const_fn)]
19+
#![feature(core_intrinsics)]
1820
#![feature(rand)]
1921
#![feature(conservative_impl_trait)]
2022

2123
extern crate graphviz;
2224
#[macro_use] extern crate rustc;
23-
extern crate rustc_data_structures;
25+
#[macro_use] extern crate rustc_data_structures;
2426
extern crate serialize as rustc_serialize;
2527

2628
#[macro_use] extern crate log;

src/librustc_incremental/persist/data.rs

+1-25
Original file line numberDiff line numberDiff line change
@@ -65,31 +65,7 @@ impl SerializedDepGraph {
6565
}
6666
}
6767

68-
/// The index of a DepNode in the SerializedDepGraph::nodes array.
69-
#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Debug,
70-
RustcEncodable, RustcDecodable)]
71-
pub struct DepNodeIndex(pub u32);
72-
73-
impl DepNodeIndex {
74-
#[inline]
75-
pub fn new(idx: usize) -> DepNodeIndex {
76-
assert!(idx <= ::std::u32::MAX as usize);
77-
DepNodeIndex(idx as u32)
78-
}
79-
}
80-
81-
impl Idx for DepNodeIndex {
82-
#[inline]
83-
fn new(idx: usize) -> Self {
84-
assert!(idx <= ::std::u32::MAX as usize);
85-
DepNodeIndex(idx as u32)
86-
}
87-
88-
#[inline]
89-
fn index(self) -> usize {
90-
self.0 as usize
91-
}
92-
}
68+
newtype_index!(DepNodeIndex);
9369

9470
#[derive(Debug, RustcEncodable, RustcDecodable)]
9571
pub struct SerializedWorkProduct {

src/librustc_incremental/persist/save.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc::util::common::time;
1919
use rustc::util::nodemap::DefIdMap;
2020
use rustc_data_structures::fx::FxHashMap;
2121
use rustc_data_structures::graph;
22-
use rustc_data_structures::indexed_vec::IndexVec;
22+
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
2323
use rustc_serialize::Encodable as RustcEncodable;
2424
use rustc_serialize::opaque::Encoder;
2525
use std::io::{self, Cursor, Write};

0 commit comments

Comments
 (0)