Skip to content

Commit 4491ea5

Browse files
committed
Auto merge of #44893 - spastorino:remove_new_and_index, r=nikomatsakis
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
2 parents b7041bf + e0e14c9 commit 4491ea5

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

src/librustc/dep_graph/graph.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -569,28 +569,20 @@ pub(super) struct DepNodeIndexNew {
569569
}
570570

571571
impl Idx for DepNodeIndexNew {
572-
fn new(idx: usize) -> Self {
573-
DepNodeIndexNew::new(idx)
572+
fn new(v: usize) -> DepNodeIndexNew {
573+
assert!((v & 0xFFFF_FFFF) == v);
574+
DepNodeIndexNew { index: v as u32 }
574575
}
576+
575577
fn index(self) -> usize {
576-
self.index()
578+
self.index as usize
577579
}
578580
}
579581

580582
impl DepNodeIndexNew {
581-
582583
const INVALID: DepNodeIndexNew = DepNodeIndexNew {
583584
index: ::std::u32::MAX,
584585
};
585-
586-
fn new(v: usize) -> DepNodeIndexNew {
587-
assert!((v & 0xFFFF_FFFF) == v);
588-
DepNodeIndexNew { index: v as u32 }
589-
}
590-
591-
fn index(self) -> usize {
592-
self.index as usize
593-
}
594586
}
595587

596588
#[derive(Clone, Debug, PartialEq)]

src/librustc/dep_graph/serialized.rs

-8
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ use rustc_data_structures::indexed_vec::{IndexVec, Idx};
1919
RustcEncodable, RustcDecodable)]
2020
pub struct SerializedDepNodeIndex(pub u32);
2121

22-
impl SerializedDepNodeIndex {
23-
#[inline]
24-
pub fn new(idx: usize) -> SerializedDepNodeIndex {
25-
assert!(idx <= ::std::u32::MAX as usize);
26-
SerializedDepNodeIndex(idx as u32)
27-
}
28-
}
29-
3022
impl Idx for SerializedDepNodeIndex {
3123
#[inline]
3224
fn new(idx: usize) -> Self {

0 commit comments

Comments
 (0)