]> git.lizzy.rs Git - rust.git/commitdiff
Mark Unique as perma-unstable, with the feature renamed to ptr_internals.
authorSimon Sapin <simon.sapin@exyr.org>
Fri, 22 Dec 2017 18:29:16 +0000 (19:29 +0100)
committerSimon Sapin <simon.sapin@exyr.org>
Sat, 20 Jan 2018 10:09:23 +0000 (11:09 +0100)
src/doc/nomicon
src/liballoc/lib.rs
src/libcore/ptr.rs
src/libcore/tests/lib.rs
src/libcore/tests/ptr.rs
src/libstd/lib.rs
src/libstd/panic.rs
src/test/run-pass/issue-23433.rs

index 2f7b05fd5939aa49d52c4ab309b9a47776ba7bd8..fec3182d0b0a3cf8122e192b3270064a5b19be5b 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 2f7b05fd5939aa49d52c4ab309b9a47776ba7bd8
+Subproject commit fec3182d0b0a3cf8122e192b3270064a5b19be5b
index eaad6f1116f00dec7dc5c52ad7c1debfff7fe217..07e4ccc45a9b3ced4826de35398d3120c1fd2a9b 100644 (file)
 #![feature(pattern)]
 #![feature(placement_in_syntax)]
 #![feature(placement_new_protocol)]
+#![feature(ptr_internals)]
 #![feature(rustc_attrs)]
 #![feature(slice_get_slice)]
 #![feature(slice_patterns)]
 #![feature(trusted_len)]
 #![feature(unboxed_closures)]
 #![feature(unicode)]
-#![feature(unique)]
 #![feature(unsize)]
 #![feature(allocator_internals)]
 #![feature(on_unimplemented)]
index 89ecb3457fcb69baf43ccc94fbbaa1b50196df15..e39c520880a661b74c353cd50372acb6054735b4 100644 (file)
@@ -2330,8 +2330,9 @@ fn ge(&self, other: &*mut T) -> bool { *self >= *other }
 ///
 /// Unlike `*mut T`, `Unique<T>` is covariant over `T`. This should always be correct
 /// for any type which upholds Unique's aliasing requirements.
-#[unstable(feature = "unique", reason = "needs an RFC to flesh out design",
-           issue = "27730")]
+#[unstable(feature = "ptr_internals", issue = "0",
+           reason = "use NonNull instead and consider PhantomData<T> \
+                     (if you also use #[may_dangle]), Send, and/or Sync")]
 pub struct Unique<T: ?Sized> {
     pointer: NonZero<*const T>,
     // NOTE: this marker has no consequences for variance, but is necessary
@@ -2342,7 +2343,7 @@ pub struct Unique<T: ?Sized> {
     _marker: PhantomData<T>,
 }
 
-#[unstable(feature = "unique", issue = "27730")]
+#[unstable(feature = "ptr_internals", issue = "0")]
 impl<T: ?Sized> fmt::Debug for Unique<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{:p}", self.as_ptr())
@@ -2353,17 +2354,17 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 /// reference is unaliased. Note that this aliasing invariant is
 /// unenforced by the type system; the abstraction using the
 /// `Unique` must enforce it.
-#[unstable(feature = "unique", issue = "27730")]
+#[unstable(feature = "ptr_internals", issue = "0")]
 unsafe impl<T: Send + ?Sized> Send for Unique<T> { }
 
 /// `Unique` pointers are `Sync` if `T` is `Sync` because the data they
 /// reference is unaliased. Note that this aliasing invariant is
 /// unenforced by the type system; the abstraction using the
 /// `Unique` must enforce it.
-#[unstable(feature = "unique", issue = "27730")]
+#[unstable(feature = "ptr_internals", issue = "0")]
 unsafe impl<T: Sync + ?Sized> Sync for Unique<T> { }
 
-#[unstable(feature = "unique", issue = "27730")]
+#[unstable(feature = "ptr_internals", issue = "0")]
 impl<T: Sized> Unique<T> {
     /// Creates a new `Unique` that is dangling, but well-aligned.
     ///
@@ -2377,14 +2378,13 @@ pub fn empty() -> Self {
     }
 }
 
-#[unstable(feature = "unique", issue = "27730")]
+#[unstable(feature = "ptr_internals", issue = "0")]
 impl<T: ?Sized> Unique<T> {
     /// Creates a new `Unique`.
     ///
     /// # Safety
     ///
     /// `ptr` must be non-null.
-    #[unstable(feature = "unique", issue = "27730")]
     pub const unsafe fn new_unchecked(ptr: *mut T) -> Self {
         Unique { pointer: NonZero::new_unchecked(ptr), _marker: PhantomData }
     }
@@ -2418,41 +2418,41 @@ pub unsafe fn as_mut(&mut self) -> &mut T {
     }
 }
 
-#[unstable(feature = "unique", issue = "27730")]
+#[unstable(feature = "ptr_internals", issue = "0")]
 impl<T: ?Sized> Clone for Unique<T> {
     fn clone(&self) -> Self {
         *self
     }
 }
 
-#[unstable(feature = "unique", issue = "27730")]
+#[unstable(feature = "ptr_internals", issue = "0")]
 impl<T: ?Sized> Copy for Unique<T> { }
 
-#[unstable(feature = "unique", issue = "27730")]
+#[unstable(feature = "ptr_internals", issue = "0")]
 impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> { }
 
-#[unstable(feature = "unique", issue = "27730")]
+#[unstable(feature = "ptr_internals", issue = "0")]
 impl<T: ?Sized> fmt::Pointer for Unique<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         fmt::Pointer::fmt(&self.as_ptr(), f)
     }
 }
 
-#[unstable(feature = "unique", issue = "27730")]
+#[unstable(feature = "ptr_internals", issue = "0")]
 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 }
     }
 }
 
-#[unstable(feature = "unique", issue = "27730")]
+#[unstable(feature = "ptr_internals", issue = "0")]
 impl<'a, T: ?Sized> From<&'a T> for Unique<T> {
     fn from(reference: &'a T) -> Self {
         Unique { pointer: NonZero::from(reference), _marker: PhantomData }
     }
 }
 
-#[unstable(feature = "unique", issue = "27730")]
+#[unstable(feature = "ptr_internals", issue = "0")]
 impl<'a, T: ?Sized> From<NonNull<T>> for Unique<T> {
     fn from(p: NonNull<T>) -> Self {
         Unique { pointer: p.pointer, _marker: PhantomData }
index 2c0009569d75d60dccb391fe2a3a79332f96f929..bc7052d676d0c6b6c0e210d076cb1992c237036a 100644 (file)
@@ -27,6 +27,7 @@
 #![feature(iterator_try_fold)]
 #![feature(iter_rfind)]
 #![feature(iter_rfold)]
+#![feature(nonnull)]
 #![feature(nonzero)]
 #![feature(pattern)]
 #![feature(raw)]
@@ -41,7 +42,6 @@
 #![feature(trusted_len)]
 #![feature(try_from)]
 #![feature(try_trait)]
-#![feature(unique)]
 #![feature(exact_chunks)]
 
 extern crate core;
index 98436f0e1d1cd968d613e70acfe8995c8b8a5257..00f87336f3c80c863f2b3bdff684d429e9b50411 100644 (file)
@@ -249,9 +249,9 @@ fn test_set_memory() {
 }
 
 #[test]
-fn test_unsized_unique() {
+fn test_unsized_nonnull() {
     let xs: &[i32] = &[1, 2, 3];
-    let ptr = unsafe { Unique::new_unchecked(xs as *const [i32] as *mut [i32]) };
+    let ptr = unsafe { NonNull::new_unchecked(xs as *const [i32] as *mut [i32]) };
     let ys = unsafe { ptr.as_ref() };
     let zs: &[i32] = &[1, 2, 3];
     assert!(ys == zs);
index 8a1ba32f7dc2489c5e2a7382b09cade5cd606389..9f65d61658cea4378a155fd534d63049191bc6d3 100644 (file)
 #![feature(placement_in_syntax)]
 #![feature(placement_new_protocol)]
 #![feature(prelude_import)]
+#![feature(ptr_internals)]
 #![feature(rand)]
 #![feature(raw)]
 #![feature(repr_align)]
 #![feature(try_from)]
 #![feature(unboxed_closures)]
 #![feature(unicode)]
-#![feature(unique)]
 #![feature(untagged_unions)]
 #![feature(unwind_attributes)]
 #![feature(vec_push_all)]
index 68584b7cf25f81ec377508caf0088769f3a30151..6f7d8ddb7706e7f45df3516a784e208ca0d19a6b 100644 (file)
@@ -196,7 +196,7 @@ impl<'a, T: RefUnwindSafe + ?Sized> UnwindSafe for &'a T {}
 impl<T: RefUnwindSafe + ?Sized> UnwindSafe for *const T {}
 #[stable(feature = "catch_unwind", since = "1.9.0")]
 impl<T: RefUnwindSafe + ?Sized> UnwindSafe for *mut T {}
-#[unstable(feature = "unique", issue = "27730")]
+#[unstable(feature = "ptr_internals", issue = "0")]
 impl<T: UnwindSafe + ?Sized> UnwindSafe for Unique<T> {}
 #[unstable(feature = "nonnull", issue = "27730")]
 impl<T: RefUnwindSafe + ?Sized> UnwindSafe for NonNull<T> {}
index aa13d6fad47c9f188bf4e855438559467caa99ec..37cc1b134c3b912b10dc6bcda3f9328c9497a05f 100644 (file)
 
 // Don't fail if we encounter a NonZero<*T> where T is an unsized type
 
-#![feature(unique)]
+#![feature(nonnull)]
 
-use std::ptr::Unique;
+use std::ptr::NonNull;
 
 fn main() {
     let mut a = [0u8; 5];
-    let b: Option<Unique<[u8]>> = Some(Unique::from(&mut a));
+    let b: Option<NonNull<[u8]>> = Some(NonNull::from(&mut a));
     match b {
         Some(_) => println!("Got `Some`"),
         None => panic!("Unexpected `None`"),