Skip to content

Commit

Permalink
Stabilize num::NonZeroU*
Browse files Browse the repository at this point in the history
Tracking issue: #49137
  • Loading branch information
SimonSapin committed May 16, 2018
1 parent c536639 commit 89d9ca9
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 21 deletions.
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
#![feature(lang_items)]
#![feature(libc)]
#![feature(needs_allocator)]
#![feature(nonzero)]
#![feature(optin_builtin_traits)]
#![feature(pattern)]
#![feature(pin)]
Expand Down
16 changes: 7 additions & 9 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ use ops;
use str::FromStr;

macro_rules! impl_nonzero_fmt {
( #[$stability: meta] ( $( $Trait: ident ),+ ) for $Ty: ident ) => {
( ( $( $Trait: ident ),+ ) for $Ty: ident ) => {
$(
#[$stability]
#[stable(feature = "nonzero", since = "1.28.0")]
impl fmt::$Trait for $Ty {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand All @@ -35,7 +35,7 @@ macro_rules! impl_nonzero_fmt {
}

macro_rules! nonzero_integers {
( #[$stability: meta] $( $Ty: ident($Int: ty); )+ ) => {
( $( $Ty: ident($Int: ty); )+ ) => {
$(
/// An integer that is known not to equal zero.
///
Expand All @@ -46,7 +46,7 @@ macro_rules! nonzero_integers {
/// use std::mem::size_of;
/// assert_eq!(size_of::<Option<std::num::NonZeroU32>>(), size_of::<u32>());
/// ```
#[$stability]
#[stable(feature = "nonzero", since = "1.28.0")]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct $Ty(NonZero<$Int>);

Expand All @@ -56,14 +56,14 @@ macro_rules! nonzero_integers {
/// # Safety
///
/// The value must not be zero.
#[$stability]
#[stable(feature = "nonzero", since = "1.28.0")]
#[inline]
pub const unsafe fn new_unchecked(n: $Int) -> Self {
$Ty(NonZero(n))
}

/// Create a non-zero if the given value is not zero.
#[$stability]
#[stable(feature = "nonzero", since = "1.28.0")]
#[inline]
pub fn new(n: $Int) -> Option<Self> {
if n != 0 {
Expand All @@ -74,7 +74,7 @@ macro_rules! nonzero_integers {
}

/// Returns the value as a primitive type.
#[$stability]
#[stable(feature = "nonzero", since = "1.28.0")]
#[inline]
pub fn get(self) -> $Int {
self.0 .0
Expand All @@ -83,15 +83,13 @@ macro_rules! nonzero_integers {
}

impl_nonzero_fmt! {
#[$stability]
(Debug, Display, Binary, Octal, LowerHex, UpperHex) for $Ty
}
)+
}
}

nonzero_integers! {
#[unstable(feature = "nonzero", issue = "49137")]
NonZeroU8(u8);
NonZeroU16(u16);
NonZeroU32(u32);
Expand Down
1 change: 0 additions & 1 deletion src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#![feature(iterator_step_by)]
#![feature(iterator_flatten)]
#![feature(iterator_repeat_with)]
#![feature(nonzero)]
#![feature(pattern)]
#![feature(range_is_empty)]
#![feature(raw)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#![feature(never_type)]
#![feature(exhaustive_patterns)]
#![feature(non_exhaustive)]
#![feature(nonzero)]
#![feature(proc_macro_internals)]
#![feature(quote)]
#![feature(optin_builtin_traits)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]

#![feature(collections_range)]
#![feature(nonzero)]
#![feature(unboxed_closures)]
#![feature(fn_traits)]
#![feature(unsize)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(exhaustive_patterns)]
#![feature(range_contains)]
#![feature(rustc_diagnostic_macros)]
#![feature(nonzero)]
#![feature(inclusive_range_methods)]
#![feature(crate_visibility_modifier)]
#![feature(never_type)]
Expand Down
1 change: 0 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@
#![feature(needs_panic_runtime)]
#![feature(never_type)]
#![feature(exhaustive_patterns)]
#![feature(nonzero)]
#![feature(num_bits_bytes)]
#![feature(old_wrapping)]
#![feature(on_unimplemented)]
Expand Down
3 changes: 1 addition & 2 deletions src/libstd/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError}
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::num::Wrapping;

#[unstable(feature = "nonzero", issue = "49137")]
#[allow(deprecated)]
#[stable(feature = "nonzero", since = "1.28.0")]
pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize};

#[cfg(test)] use fmt;
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/ctfe/tuple-struct-constructors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// https://github.com/rust-lang/rust/issues/41898

#![feature(nonzero)]
use std::num::NonZeroU64;

fn main() {
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/enum-null-pointer-opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(nonzero, core)]

use std::mem::size_of;
use std::num::NonZeroUsize;
use std::ptr::NonNull;
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/print_type_sizes/niche-filling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
// padding and overall computed sizes can be quite different.

#![feature(start)]
#![feature(nonzero)]
#![allow(dead_code)]

use std::num::NonZeroU32;
Expand Down

0 comments on commit 89d9ca9

Please sign in to comment.