change from tuple struct to brace struct
This commit is contained in:
parent
5aee959e9f
commit
6ccf9b8134
6 changed files with 23 additions and 21 deletions
|
|
@ -44,7 +44,7 @@ newtype_index! {
|
|||
}
|
||||
|
||||
impl DepNodeIndex {
|
||||
const INVALID: DepNodeIndex = DepNodeIndex(::std::u32::MAX);
|
||||
const INVALID: DepNodeIndex = DepNodeIndex { private: ::std::u32::MAX };
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
|
|
@ -1127,14 +1127,14 @@ impl DepNodeColorMap {
|
|||
match self.values[index] {
|
||||
COMPRESSED_NONE => None,
|
||||
COMPRESSED_RED => Some(DepNodeColor::Red),
|
||||
value => Some(DepNodeColor::Green(DepNodeIndex(value - COMPRESSED_FIRST_GREEN)))
|
||||
value => Some(DepNodeColor::Green(DepNodeIndex { private: value - COMPRESSED_FIRST_GREEN })),
|
||||
}
|
||||
}
|
||||
|
||||
fn insert(&mut self, index: SerializedDepNodeIndex, color: DepNodeColor) {
|
||||
self.values[index] = match color {
|
||||
DepNodeColor::Red => COMPRESSED_RED,
|
||||
DepNodeColor::Green(index) => index.0 + COMPRESSED_FIRST_GREEN,
|
||||
DepNodeColor::Green(index) => index.private + COMPRESSED_FIRST_GREEN,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,15 +41,15 @@ newtype_index! {
|
|||
impl CrateNum {
|
||||
pub fn new(x: usize) -> CrateNum {
|
||||
assert!(x < (u32::MAX as usize));
|
||||
CrateNum(x as u32)
|
||||
CrateNum { private: x as u32 }
|
||||
}
|
||||
|
||||
pub fn from_u32(x: u32) -> CrateNum {
|
||||
CrateNum(x)
|
||||
CrateNum { private: x }
|
||||
}
|
||||
|
||||
pub fn as_usize(&self) -> usize {
|
||||
self.0 as usize
|
||||
self.private as usize
|
||||
}
|
||||
|
||||
pub fn as_u32(&self) -> u32 {
|
||||
|
|
@ -61,7 +61,7 @@ impl CrateNum {
|
|||
|
||||
impl fmt::Display for CrateNum {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Display::fmt(&self.0, f)
|
||||
fmt::Display::fmt(&self.private, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ newtype_index! {
|
|||
}
|
||||
}
|
||||
|
||||
impl_stable_hash_for!(tuple_struct ::middle::region::FirstStatementIndex { idx });
|
||||
impl_stable_hash_for!(struct ::middle::region::FirstStatementIndex { private });
|
||||
|
||||
impl From<ScopeData> for Scope {
|
||||
#[inline]
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ pub struct Mir<'tcx> {
|
|||
}
|
||||
|
||||
/// where execution begins
|
||||
pub const START_BLOCK: BasicBlock = BasicBlock(0);
|
||||
pub const START_BLOCK: BasicBlock = BasicBlock { private: 0 };
|
||||
|
||||
impl<'tcx> Mir<'tcx> {
|
||||
pub fn new(
|
||||
|
|
@ -239,7 +239,7 @@ impl<'tcx> Mir<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn local_kind(&self, local: Local) -> LocalKind {
|
||||
let index = local.0 as usize;
|
||||
let index = local.private as usize;
|
||||
if index == 0 {
|
||||
debug_assert!(
|
||||
self.local_decls[local].mutability == Mutability::Mut,
|
||||
|
|
|
|||
|
|
@ -1274,7 +1274,7 @@ impl DebruijnIndex {
|
|||
/// you would need to shift the index for `'a` into 1 new binder.
|
||||
#[must_use]
|
||||
pub const fn shifted_in(self, amount: u32) -> DebruijnIndex {
|
||||
DebruijnIndex(self.0 + amount)
|
||||
DebruijnIndex { private: self.private + amount }
|
||||
}
|
||||
|
||||
/// Update this index in place by shifting it "in" through
|
||||
|
|
@ -1287,7 +1287,7 @@ impl DebruijnIndex {
|
|||
/// `amount` number of new binders.
|
||||
#[must_use]
|
||||
pub const fn shifted_out(self, amount: u32) -> DebruijnIndex {
|
||||
DebruijnIndex(self.0 - amount)
|
||||
DebruijnIndex { private: self.private - amount }
|
||||
}
|
||||
|
||||
/// Update in place by shifting out from `amount` binders.
|
||||
|
|
@ -1316,11 +1316,11 @@ impl DebruijnIndex {
|
|||
/// bound by one of the binders we are shifting out of, that is an
|
||||
/// error (and should fail an assertion failure).
|
||||
pub fn shifted_out_to_binder(self, to_binder: DebruijnIndex) -> Self {
|
||||
self.shifted_out((to_binder.0 - INNERMOST.0) as u32)
|
||||
self.shifted_out((to_binder.private - INNERMOST.private) as u32)
|
||||
}
|
||||
}
|
||||
|
||||
impl_stable_hash_for!(tuple_struct DebruijnIndex { index });
|
||||
impl_stable_hash_for!(struct DebruijnIndex { private });
|
||||
|
||||
/// Region utilities
|
||||
impl RegionKind {
|
||||
|
|
|
|||
|
|
@ -97,7 +97,9 @@ macro_rules! newtype_index {
|
|||
@vis [$v:vis]
|
||||
@debug_format [$debug_format:tt]) => (
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, $($derives),*)]
|
||||
$v struct $type(u32);
|
||||
$v struct $type {
|
||||
private: u32
|
||||
}
|
||||
|
||||
impl $type {
|
||||
/// Extract value of this index as an integer.
|
||||
|
|
@ -111,12 +113,12 @@ macro_rules! newtype_index {
|
|||
#[inline]
|
||||
fn new(value: usize) -> Self {
|
||||
assert!(value < ($max) as usize);
|
||||
$type(value as u32)
|
||||
$type { private: value as u32 }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn index(self) -> usize {
|
||||
self.0 as usize
|
||||
self.private as usize
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -151,13 +153,13 @@ macro_rules! newtype_index {
|
|||
|
||||
impl From<$type> for u32 {
|
||||
fn from(v: $type) -> u32 {
|
||||
v.0
|
||||
v.private
|
||||
}
|
||||
}
|
||||
|
||||
impl From<$type> for usize {
|
||||
fn from(v: $type) -> usize {
|
||||
v.0 as usize
|
||||
v.private as usize
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -193,7 +195,7 @@ macro_rules! newtype_index {
|
|||
@debug_format [$debug_format:tt]) => (
|
||||
impl ::std::fmt::Debug for $type {
|
||||
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||
write!(fmt, $debug_format, self.0)
|
||||
write!(fmt, $debug_format, self.private)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -376,7 +378,7 @@ macro_rules! newtype_index {
|
|||
const $name:ident = $constant:expr,
|
||||
$($tokens:tt)*) => (
|
||||
$(#[doc = $doc])*
|
||||
pub const $name: $type = $type($constant);
|
||||
pub const $name: $type = $type { private: $constant };
|
||||
newtype_index!(
|
||||
@derives [$($derives,)*]
|
||||
@type [$type]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue