Skip to content

Commit 912a3a5

Browse files
committed
Make DepNodeIndex use newtype_index macro
1 parent a6885cb commit 912a3a5

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

src/librustc/dep_graph/graph.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,10 @@ pub struct DepGraph {
4545
}
4646

4747

48-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
49-
pub struct DepNodeIndex {
50-
index: u32,
51-
}
52-
53-
impl Idx for DepNodeIndex {
54-
fn new(idx: usize) -> Self {
55-
debug_assert!((idx & 0xFFFF_FFFF) == idx);
56-
DepNodeIndex { index: idx as u32 }
57-
}
58-
fn index(self) -> usize {
59-
self.index as usize
60-
}
61-
}
48+
newtype_index!(DepNodeIndex);
6249

6350
impl DepNodeIndex {
64-
const INVALID: DepNodeIndex = DepNodeIndex {
65-
index: ::std::u32::MAX,
66-
};
51+
const INVALID: DepNodeIndex = DepNodeIndex(::std::u32::MAX);
6752
}
6853

6954
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]

0 commit comments

Comments
 (0)