From 70c3a3da6d6aa9b818c76dc0c3afd31fb2249cfb Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 27 Sep 2017 16:31:31 -0300 Subject: [PATCH 1/2] Remove DepNodeIndexNew::new and ::index, they are already impl for Idx --- src/librustc/dep_graph/graph.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 71a7ee84cd144..d9770db9d69a2 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)] From e0e14c9a5b141cb86c1b2cde85c35388ba63ad23 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 27 Sep 2017 16:41:35 -0300 Subject: [PATCH 2/2] Remove SerializedDepNodeIndex::new it is already impl for Idx --- src/librustc/dep_graph/serialized.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/librustc/dep_graph/serialized.rs b/src/librustc/dep_graph/serialized.rs index 21beac9214eef..6110c270086fe 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 {