Skip to content

Commit 80785a5

Browse files
committed
Auto merge of #49324 - SimonSapin:unsigned, r=alexcrichton
Deprecate signed std::num::NonZeroI* with a call for use cases CC #49137 (comment)
2 parents f1c21b0 + cea018f commit 80785a5

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

src/libcore/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#![feature(lang_items)]
8787
#![feature(link_llvm_intrinsics)]
8888
#![feature(exhaustive_patterns)]
89+
#![feature(macro_at_most_once_rep)]
8990
#![feature(no_core)]
9091
#![feature(on_unimplemented)]
9192
#![feature(optin_builtin_traits)]

src/libcore/num/mod.rs

+23-7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ macro_rules! impl_nonzero_fmt {
2323
( #[$stability: meta] ( $( $Trait: ident ),+ ) for $Ty: ident ) => {
2424
$(
2525
#[$stability]
26+
#[allow(deprecated)]
2627
impl fmt::$Trait for $Ty {
2728
#[inline]
2829
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -34,7 +35,7 @@ macro_rules! impl_nonzero_fmt {
3435
}
3536

3637
macro_rules! nonzero_integers {
37-
( #[$stability: meta] $( $Ty: ident($Int: ty); )+ ) => {
38+
( #[$stability: meta] #[$deprecation: meta] $( $Ty: ident($Int: ty); )+ ) => {
3839
$(
3940
/// An integer that is known not to equal zero.
4041
///
@@ -46,6 +47,7 @@ macro_rules! nonzero_integers {
4647
/// assert_eq!(size_of::<Option<std::num::NonZeroU32>>(), size_of::<u32>());
4748
/// ```
4849
#[$stability]
50+
#[$deprecation]
4951
#[allow(deprecated)]
5052
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5153
pub struct $Ty(NonZero<$Int>);
@@ -93,12 +95,26 @@ macro_rules! nonzero_integers {
9395

9496
nonzero_integers! {
9597
#[unstable(feature = "nonzero", issue = "49137")]
96-
NonZeroU8(u8); NonZeroI8(i8);
97-
NonZeroU16(u16); NonZeroI16(i16);
98-
NonZeroU32(u32); NonZeroI32(i32);
99-
NonZeroU64(u64); NonZeroI64(i64);
100-
NonZeroU128(u128); NonZeroI128(i128);
101-
NonZeroUsize(usize); NonZeroIsize(isize);
98+
#[allow(deprecated)] // Redundant, works around "error: inconsistent lockstep iteration"
99+
NonZeroU8(u8);
100+
NonZeroU16(u16);
101+
NonZeroU32(u32);
102+
NonZeroU64(u64);
103+
NonZeroU128(u128);
104+
NonZeroUsize(usize);
105+
}
106+
107+
nonzero_integers! {
108+
#[unstable(feature = "nonzero", issue = "49137")]
109+
#[rustc_deprecated(since = "1.26.0", reason = "\
110+
signed non-zero integers are considered for removal due to lack of known use cases. \
111+
If you’re using them, please comment on https://github.com/rust-lang/rust/issues/49137")]
112+
NonZeroI8(i8);
113+
NonZeroI16(i16);
114+
NonZeroI32(i32);
115+
NonZeroI64(i64);
116+
NonZeroI128(i128);
117+
NonZeroIsize(isize);
102118
}
103119

104120
/// Provides intentionally-wrapped arithmetic on `T`.

src/libstd/num.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError}
2222
pub use core::num::Wrapping;
2323

2424
#[unstable(feature = "nonzero", issue = "49137")]
25+
#[allow(deprecated)]
2526
pub use core::num::{
2627
NonZeroU8, NonZeroI8, NonZeroU16, NonZeroI16, NonZeroU32, NonZeroI32,
2728
NonZeroU64, NonZeroI64, NonZeroU128, NonZeroI128, NonZeroUsize, NonZeroIsize,

0 commit comments

Comments
 (0)