about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-09-30 06:56:49 +0000
committerbors <bors@rust-lang.org>2017-09-30 06:56:49 +0000
commit4491ea5a3f21b63e7d0f39d9294308673a6e9715 (patch)
tree0ff04221845794e4443bf55da7979254e5ff463f
parentb7041bfab3a83702a8026fb7a18d8ea7d54cc648 (diff)
parente0e14c9a5b141cb86c1b2cde85c35388ba63ad23 (diff)
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 https://github.com/rust-lang/rust/pull/44889
-rw-r--r--src/librustc/dep_graph/graph.rs18
-rw-r--r--src/librustc/dep_graph/serialized.rs8
2 files changed, 5 insertions, 21 deletions
diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs
index 71a7ee84cd1..d9770db9d69 100644
--- a/src/librustc/dep_graph/graph.rs
+++ b/src/librustc/dep_graph/graph.rs
@@ -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)]
diff --git a/src/librustc/dep_graph/serialized.rs b/src/librustc/dep_graph/serialized.rs
index 21beac9214e..6110c270086 100644
--- a/src/librustc/dep_graph/serialized.rs
+++ b/src/librustc/dep_graph/serialized.rs
@@ -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 {