Deprecate signed std::num::NonZeroI* with a call for use cases
This commit is contained in:
@@ -86,6 +86,7 @@
|
|||||||
#![feature(lang_items)]
|
#![feature(lang_items)]
|
||||||
#![feature(link_llvm_intrinsics)]
|
#![feature(link_llvm_intrinsics)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
|
#![feature(macro_at_most_once_rep)]
|
||||||
#![feature(no_core)]
|
#![feature(no_core)]
|
||||||
#![feature(on_unimplemented)]
|
#![feature(on_unimplemented)]
|
||||||
#![feature(optin_builtin_traits)]
|
#![feature(optin_builtin_traits)]
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ macro_rules! impl_nonzero_fmt {
|
|||||||
( #[$stability: meta] ( $( $Trait: ident ),+ ) for $Ty: ident ) => {
|
( #[$stability: meta] ( $( $Trait: ident ),+ ) for $Ty: ident ) => {
|
||||||
$(
|
$(
|
||||||
#[$stability]
|
#[$stability]
|
||||||
|
#[allow(deprecated)]
|
||||||
impl fmt::$Trait for $Ty {
|
impl fmt::$Trait for $Ty {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
@@ -34,7 +35,7 @@ macro_rules! impl_nonzero_fmt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! nonzero_integers {
|
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.
|
/// An integer that is known not to equal zero.
|
||||||
///
|
///
|
||||||
@@ -46,6 +47,7 @@ macro_rules! nonzero_integers {
|
|||||||
/// assert_eq!(size_of::<Option<std::num::NonZeroU32>>(), size_of::<u32>());
|
/// assert_eq!(size_of::<Option<std::num::NonZeroU32>>(), size_of::<u32>());
|
||||||
/// ```
|
/// ```
|
||||||
#[$stability]
|
#[$stability]
|
||||||
|
#[$deprecation]
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||||
pub struct $Ty(NonZero<$Int>);
|
pub struct $Ty(NonZero<$Int>);
|
||||||
@@ -93,12 +95,26 @@ macro_rules! nonzero_integers {
|
|||||||
|
|
||||||
nonzero_integers! {
|
nonzero_integers! {
|
||||||
#[unstable(feature = "nonzero", issue = "49137")]
|
#[unstable(feature = "nonzero", issue = "49137")]
|
||||||
NonZeroU8(u8); NonZeroI8(i8);
|
#[allow(deprecated)] // Redundant, works around "error: inconsistent lockstep iteration"
|
||||||
NonZeroU16(u16); NonZeroI16(i16);
|
NonZeroU8(u8);
|
||||||
NonZeroU32(u32); NonZeroI32(i32);
|
NonZeroU16(u16);
|
||||||
NonZeroU64(u64); NonZeroI64(i64);
|
NonZeroU32(u32);
|
||||||
NonZeroU128(u128); NonZeroI128(i128);
|
NonZeroU64(u64);
|
||||||
NonZeroUsize(usize); NonZeroIsize(isize);
|
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`.
|
/// Provides intentionally-wrapped arithmetic on `T`.
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError}
|
|||||||
pub use core::num::Wrapping;
|
pub use core::num::Wrapping;
|
||||||
|
|
||||||
#[unstable(feature = "nonzero", issue = "49137")]
|
#[unstable(feature = "nonzero", issue = "49137")]
|
||||||
|
#[allow(deprecated)]
|
||||||
pub use core::num::{
|
pub use core::num::{
|
||||||
NonZeroU8, NonZeroI8, NonZeroU16, NonZeroI16, NonZeroU32, NonZeroI32,
|
NonZeroU8, NonZeroI8, NonZeroU16, NonZeroI16, NonZeroU32, NonZeroI32,
|
||||||
NonZeroU64, NonZeroI64, NonZeroU128, NonZeroI128, NonZeroUsize, NonZeroIsize,
|
NonZeroU64, NonZeroI64, NonZeroU128, NonZeroI128, NonZeroUsize, NonZeroIsize,
|
||||||
|
|||||||
Reference in New Issue
Block a user