Skip to content

Commit

Permalink
Use normal u32 for newtype_index
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHinshelwood committed Nov 11, 2018
1 parent d8c8173 commit 5e175e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_data_structures/indexed_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 5e175e6

Please sign in to comment.