提交 89d9ca9b 编写于 作者: S Simon Sapin

Stabilize num::NonZeroU*

Tracking issue: https://github.com/rust-lang/rust/issues/49137
上级 c536639c
......@@ -102,7 +102,6 @@
#![feature(lang_items)]
#![feature(libc)]
#![feature(needs_allocator)]
#![feature(nonzero)]
#![feature(optin_builtin_traits)]
#![feature(pattern)]
#![feature(pin)]
......
......@@ -21,9 +21,9 @@
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 {
......@@ -35,7 +35,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
macro_rules! nonzero_integers {
( #[$stability: meta] $( $Ty: ident($Int: ty); )+ ) => {
( $( $Ty: ident($Int: ty); )+ ) => {
$(
/// An integer that is known not to equal zero.
///
......@@ -46,7 +46,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
/// 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>);
......@@ -56,14 +56,14 @@ impl $Ty {
/// # 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 {
......@@ -74,7 +74,7 @@ pub fn new(n: $Int) -> Option<Self> {
}
/// Returns the value as a primitive type.
#[$stability]
#[stable(feature = "nonzero", since = "1.28.0")]
#[inline]
pub fn get(self) -> $Int {
self.0 .0
......@@ -83,7 +83,6 @@ pub fn get(self) -> $Int {
}
impl_nonzero_fmt! {
#[$stability]
(Debug, Display, Binary, Octal, LowerHex, UpperHex) for $Ty
}
)+
......@@ -91,7 +90,6 @@ pub fn get(self) -> $Int {
}
nonzero_integers! {
#[unstable(feature = "nonzero", issue = "49137")]
NonZeroU8(u8);
NonZeroU16(u16);
NonZeroU32(u32);
......
......@@ -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)]
......
......@@ -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)]
......
......@@ -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)]
......
......@@ -30,7 +30,6 @@
#![feature(exhaustive_patterns)]
#![feature(range_contains)]
#![feature(rustc_diagnostic_macros)]
#![feature(nonzero)]
#![feature(inclusive_range_methods)]
#![feature(crate_visibility_modifier)]
#![feature(never_type)]
......
......@@ -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)]
......
......@@ -21,8 +21,7 @@
#[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;
......
......@@ -10,7 +10,6 @@
// https://github.com/rust-lang/rust/issues/41898
#![feature(nonzero)]
use std::num::NonZeroU64;
fn main() {
......
......@@ -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;
......
......@@ -22,7 +22,6 @@
// padding and overall computed sizes can be quite different.
#![feature(start)]
#![feature(nonzero)]
#![allow(dead_code)]
use std::num::NonZeroU32;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册