Skip to content

Commit

Permalink
Auto merge of #44893 - spastorino:remove_new_and_index, r=nikomatsakis
Browse files Browse the repository at this point in the history
Remove new and index methods already implement for Idx

These are the rest of the repeated implementations for new and index methods. Follow up of #44889
  • Loading branch information
bors committed Sep 30, 2017
2 parents b7041bf + e0e14c9 commit 4491ea5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
18 changes: 5 additions & 13 deletions src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,28 +569,20 @@ pub(super) struct DepNodeIndexNew {
}

impl Idx for DepNodeIndexNew {
fn new(idx: usize) -> Self {
DepNodeIndexNew::new(idx)
fn new(v: usize) -> DepNodeIndexNew {
assert!((v & 0xFFFF_FFFF) == v);
DepNodeIndexNew { index: v as u32 }
}

fn index(self) -> usize {
self.index()
self.index as usize
}
}

impl DepNodeIndexNew {

const INVALID: DepNodeIndexNew = DepNodeIndexNew {
index: ::std::u32::MAX,
};

fn new(v: usize) -> DepNodeIndexNew {
assert!((v & 0xFFFF_FFFF) == v);
DepNodeIndexNew { index: v as u32 }
}

fn index(self) -> usize {
self.index as usize
}
}

#[derive(Clone, Debug, PartialEq)]
Expand Down
8 changes: 0 additions & 8 deletions src/librustc/dep_graph/serialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ use rustc_data_structures::indexed_vec::{IndexVec, Idx};
RustcEncodable, RustcDecodable)]
pub struct SerializedDepNodeIndex(pub u32);

impl SerializedDepNodeIndex {
#[inline]
pub fn new(idx: usize) -> SerializedDepNodeIndex {
assert!(idx <= ::std::u32::MAX as usize);
SerializedDepNodeIndex(idx as u32)
}
}

impl Idx for SerializedDepNodeIndex {
#[inline]
fn new(idx: usize) -> Self {
Expand Down

0 comments on commit 4491ea5

Please sign in to comment.