diff options
| author | bors <bors@rust-lang.org> | 2018-12-27 12:01:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-12-27 12:01:08 +0000 |
| commit | d174173552cfa031b63e8b1dabbd08943748dea1 (patch) | |
| tree | 2353d7d394275a667bf15a64be0adf7f00ca69fe /src/libcore/num | |
| parent | d2986970adae36939d13c79e3af34ff6378fad68 (diff) | |
| parent | 7a0911528058e87d22ea305695f4047572c5e067 (diff) | |
| download | rust-d174173552cfa031b63e8b1dabbd08943748dea1.tar.gz rust-d174173552cfa031b63e8b1dabbd08943748dea1.zip | |
Auto merge of #57133 - SimonSapin:zero, r=oli-obk
Remove the private generic NonZero<T> wrapper type Instead, use `#[rustc_layout_scalar_valid_range_start(1)]` directly on relevant libcore types.
Diffstat (limited to 'src/libcore/num')
| -rw-r--r-- | src/libcore/num/mod.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 3112db4ad5d..e776513770e 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -6,7 +6,6 @@ use convert::TryFrom; use fmt; use intrinsics; use mem; -use nonzero::NonZero; use ops; use str::FromStr; @@ -48,7 +47,8 @@ assert_eq!(size_of::<Option<std::num::", stringify!($Ty), ">>(), size_of::<", st #[stable(feature = "nonzero", since = "1.28.0")] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] #[repr(transparent)] - pub struct $Ty(NonZero<$Int>); + #[rustc_layout_scalar_valid_range_start(1)] + pub struct $Ty($Int); } impl $Ty { @@ -60,7 +60,7 @@ assert_eq!(size_of::<Option<std::num::", stringify!($Ty), ">>(), size_of::<", st #[stable(feature = "nonzero", since = "1.28.0")] #[inline] pub const unsafe fn new_unchecked(n: $Int) -> Self { - $Ty(NonZero(n)) + $Ty(n) } /// Create a non-zero if the given value is not zero. @@ -68,7 +68,7 @@ assert_eq!(size_of::<Option<std::num::", stringify!($Ty), ">>(), size_of::<", st #[inline] pub fn new(n: $Int) -> Option<Self> { if n != 0 { - Some($Ty(unsafe { NonZero(n) })) + Some(unsafe { $Ty(n) }) } else { None } @@ -78,7 +78,7 @@ assert_eq!(size_of::<Option<std::num::", stringify!($Ty), ">>(), size_of::<", st #[stable(feature = "nonzero", since = "1.28.0")] #[inline] pub fn get(self) -> $Int { - self.0 .0 + self.0 } } @@ -86,7 +86,7 @@ assert_eq!(size_of::<Option<std::num::", stringify!($Ty), ">>(), size_of::<", st #[stable(feature = "from_nonzero", since = "1.31.0")] impl From<$Ty> for $Int { fn from(nonzero: $Ty) -> Self { - nonzero.0 .0 + nonzero.0 } } |
