From cea018f290f05b32ca6b5bcb2f8599d20b5de75c Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sat, 24 Mar 2018 11:15:10 +0100 Subject: Deprecate signed std::num::NonZeroI* with a call for use cases --- src/libcore/num/mod.rs | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'src/libcore/num') diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index ee041e1e4f1..dcda404721c 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -23,6 +23,7 @@ macro_rules! impl_nonzero_fmt { ( #[$stability: meta] ( $( $Trait: ident ),+ ) for $Ty: ident ) => { $( #[$stability] + #[allow(deprecated)] impl fmt::$Trait for $Ty { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -34,7 +35,7 @@ macro_rules! impl_nonzero_fmt { } macro_rules! nonzero_integers { - ( #[$stability: meta] $( $Ty: ident($Int: ty); )+ ) => { + ( #[$stability: meta] #[$deprecation: meta] $( $Ty: ident($Int: ty); )+ ) => { $( /// An integer that is known not to equal zero. /// @@ -46,6 +47,7 @@ macro_rules! nonzero_integers { /// assert_eq!(size_of::>(), size_of::()); /// ``` #[$stability] + #[$deprecation] #[allow(deprecated)] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct $Ty(NonZero<$Int>); @@ -93,12 +95,26 @@ macro_rules! nonzero_integers { nonzero_integers! { #[unstable(feature = "nonzero", issue = "49137")] - NonZeroU8(u8); NonZeroI8(i8); - NonZeroU16(u16); NonZeroI16(i16); - NonZeroU32(u32); NonZeroI32(i32); - NonZeroU64(u64); NonZeroI64(i64); - NonZeroU128(u128); NonZeroI128(i128); - NonZeroUsize(usize); NonZeroIsize(isize); + #[allow(deprecated)] // Redundant, works around "error: inconsistent lockstep iteration" + NonZeroU8(u8); + NonZeroU16(u16); + NonZeroU32(u32); + NonZeroU64(u64); + NonZeroU128(u128); + NonZeroUsize(usize); +} + +nonzero_integers! { + #[unstable(feature = "nonzero", issue = "49137")] + #[rustc_deprecated(since = "1.26.0", reason = "\ + signed non-zero integers are considered for removal due to lack of known use cases. \ + If you’re using them, please comment on https://github.com/rust-lang/rust/issues/49137")] + NonZeroI8(i8); + NonZeroI16(i16); + NonZeroI32(i32); + NonZeroI64(i64); + NonZeroI128(i128); + NonZeroIsize(isize); } /// Provides intentionally-wrapped arithmetic on `T`. -- cgit 1.4.1-3-g733a5