]> git.lizzy.rs Git - rust.git/commitdiff
Deprecate core::nonzero in favor of ptr::NonNull and num::NonZero*
authorSimon Sapin <simon.sapin@exyr.org>
Fri, 16 Feb 2018 10:14:35 +0000 (11:14 +0100)
committerSimon Sapin <simon.sapin@exyr.org>
Sat, 17 Mar 2018 22:07:40 +0000 (23:07 +0100)
src/libcore/nonzero.rs
src/libcore/num/mod.rs
src/libcore/ptr.rs

index c6a1dab5617573c3976919a01a6bfb32a0dd4b59..59aaef9d66a0048ed822a699a811cb9621d43f85 100644 (file)
 
 //! Exposes the NonZero lang item which provides optimization hints.
 #![unstable(feature = "nonzero",
-            reason = "needs an RFC to flesh out the design",
+            reason = "deprecated",
             issue = "27730")]
+#![rustc_deprecated(reason = "use `std::ptr::NonNull` or `std::num::NonZero*` instead",
+                    since = "1.26.0")]
+#![allow(deprecated)]
 
 use ops::CoerceUnsized;
 
index d3556ef742b535ce0399f74c0ef4e4d41082464f..84f6ab9b764987e089f7133d9225c60c10ede178 100644 (file)
@@ -15,7 +15,7 @@
 use convert::{Infallible, TryFrom};
 use fmt;
 use intrinsics;
-use nonzero::NonZero;
+#[allow(deprecated)] use nonzero::NonZero;
 use ops;
 use str::FromStr;
 
@@ -46,9 +46,11 @@ macro_rules! nonzero_integers {
             /// assert_eq!(size_of::<Option<std::num::NonZeroU32>>(), size_of::<u32>());
             /// ```
             #[$stability]
+            #[allow(deprecated)]
             #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
             pub struct $Ty(NonZero<$Int>);
 
+            #[allow(deprecated)]
             impl $Ty {
                 /// Create a non-zero without checking the value.
                 ///
index 6270e5892b3a0b4141da929e105fe71300bed165..834a2ed09f77a203d9da0a3f1c7d5da7072bcadf 100644 (file)
@@ -23,7 +23,7 @@
 use hash;
 use marker::{PhantomData, Unsize};
 use mem;
-use nonzero::NonZero;
+#[allow(deprecated)] use nonzero::NonZero;
 
 use cmp::Ordering::{self, Less, Equal, Greater};
 
@@ -2285,6 +2285,7 @@ fn ge(&self, other: &*mut T) -> bool { *self >= *other }
 #[unstable(feature = "ptr_internals", issue = "0",
            reason = "use NonNull instead and consider PhantomData<T> \
                      (if you also use #[may_dangle]), Send, and/or Sync")]
+#[allow(deprecated)]
 pub struct Unique<T: ?Sized> {
     pointer: NonZero<*const T>,
     // NOTE: this marker has no consequences for variance, but is necessary
@@ -2332,6 +2333,7 @@ pub fn empty() -> Self {
 }
 
 #[unstable(feature = "ptr_internals", issue = "0")]
+#[allow(deprecated)]
 impl<T: ?Sized> Unique<T> {
     /// Creates a new `Unique`.
     ///
@@ -2392,6 +2394,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 #[unstable(feature = "ptr_internals", issue = "0")]
+#[allow(deprecated)]
 impl<'a, T: ?Sized> From<&'a mut T> for Unique<T> {
     fn from(reference: &'a mut T) -> Self {
         Unique { pointer: NonZero::from(reference), _marker: PhantomData }
@@ -2399,6 +2402,7 @@ fn from(reference: &'a mut T) -> Self {
 }
 
 #[unstable(feature = "ptr_internals", issue = "0")]
+#[allow(deprecated)]
 impl<'a, T: ?Sized> From<&'a T> for Unique<T> {
     fn from(reference: &'a T) -> Self {
         Unique { pointer: NonZero::from(reference), _marker: PhantomData }
@@ -2436,7 +2440,7 @@ fn from(p: NonNull<T>) -> Self {
 /// provide a public API that follows the normal shared XOR mutable rules of Rust.
 #[stable(feature = "nonnull", since = "1.25.0")]
 pub struct NonNull<T: ?Sized> {
-    pointer: NonZero<*const T>,
+    #[allow(deprecated)] pointer: NonZero<*const T>,
 }
 
 /// `NonNull` pointers are not `Send` because the data they reference may be aliased.
@@ -2463,6 +2467,7 @@ pub fn dangling() -> Self {
     }
 }
 
+#[allow(deprecated)]
 impl<T: ?Sized> NonNull<T> {
     /// Creates a new `NonNull`.
     ///
@@ -2581,6 +2586,7 @@ fn from(unique: Unique<T>) -> Self {
 }
 
 #[stable(feature = "nonnull", since = "1.25.0")]
+#[allow(deprecated)]
 impl<'a, T: ?Sized> From<&'a mut T> for NonNull<T> {
     fn from(reference: &'a mut T) -> Self {
         NonNull { pointer: NonZero::from(reference) }
@@ -2588,6 +2594,7 @@ fn from(reference: &'a mut T) -> Self {
 }
 
 #[stable(feature = "nonnull", since = "1.25.0")]
+#[allow(deprecated)]
 impl<'a, T: ?Sized> From<&'a T> for NonNull<T> {
     fn from(reference: &'a T) -> Self {
         NonNull { pointer: NonZero::from(reference) }