From 5e175e6a5db2fbfbe92719a93605425a07c30de2 Mon Sep 17 00:00:00 2001 From: JamesHinshelwood Date: Sun, 11 Nov 2018 22:15:09 +0000 Subject: [PATCH] Use normal u32 for newtype_index --- src/librustc/ty/mod.rs | 2 +- src/librustc_data_structures/indexed_vec.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index ef9b3e3efab27..bbc26dde41b56 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1498,7 +1498,7 @@ newtype_index! { impl_stable_hash_for!(struct UniverseIndex { private }); impl UniverseIndex { - pub const ROOT: UniverseIndex = UniverseIndex::from_u32_const(0); + pub const ROOT: UniverseIndex = UniverseIndex::from_u32(0); /// Returns the "next" universe index in order -- this new index /// is considered to extend all previous universes. This diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs index 89b83825d838d..83e8ff7e5ffc1 100644 --- a/src/librustc_data_structures/indexed_vec.rs +++ b/src/librustc_data_structures/indexed_vec.rs @@ -101,7 +101,7 @@ macro_rules! newtype_index { #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, $($derives),*)] #[rustc_layout_scalar_valid_range_end($max)] $v struct $type { - private: ::std::num::NonZeroU32 + private: u32 } impl $type { @@ -134,7 +134,7 @@ macro_rules! newtype_index { #[inline] $v const unsafe fn from_u32_unchecked(value: u32) -> Self { - $type { private: ::std::num::NonZeroU32::new_unchecked(value + 1) } + $type { private: value } } /// Extract value of this index as an integer. @@ -146,7 +146,7 @@ macro_rules! newtype_index { /// Extract value of this index as a usize. #[inline] $v const fn as_u32(self) -> u32 { - self.private.get() - 1 + self.private } /// Extract value of this index as a u32.