Skip to content

Commit c97c1f7

Browse files
committed
Mark Unique as perma-unstable, with the feature renamed to ptr_internals.
1 parent a2f878a commit c97c1f7

File tree

8 files changed

+25
-25
lines changed

8 files changed

+25
-25
lines changed

src/doc/nomicon

src/liballoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
#![feature(pattern)]
111111
#![feature(placement_in_syntax)]
112112
#![feature(placement_new_protocol)]
113+
#![feature(ptr_internals)]
113114
#![feature(rustc_attrs)]
114115
#![feature(slice_get_slice)]
115116
#![feature(slice_patterns)]
@@ -120,7 +121,6 @@
120121
#![feature(trusted_len)]
121122
#![feature(unboxed_closures)]
122123
#![feature(unicode)]
123-
#![feature(unique)]
124124
#![feature(unsize)]
125125
#![feature(allocator_internals)]
126126
#![feature(on_unimplemented)]

src/libcore/ptr.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,8 +2330,9 @@ impl<T: ?Sized> PartialOrd for *mut T {
23302330
///
23312331
/// Unlike `*mut T`, `Unique<T>` is covariant over `T`. This should always be correct
23322332
/// for any type which upholds Unique's aliasing requirements.
2333-
#[unstable(feature = "unique", reason = "needs an RFC to flesh out design",
2334-
issue = "27730")]
2333+
#[unstable(feature = "ptr_internals", issue = "0",
2334+
reason = "use NonNull instead and consider PhantomData<T> \
2335+
(if you also use #[may_dangle]), Send, and/or Sync")]
23352336
pub struct Unique<T: ?Sized> {
23362337
pointer: NonZero<*const T>,
23372338
// NOTE: this marker has no consequences for variance, but is necessary
@@ -2342,7 +2343,7 @@ pub struct Unique<T: ?Sized> {
23422343
_marker: PhantomData<T>,
23432344
}
23442345

2345-
#[unstable(feature = "unique", issue = "27730")]
2346+
#[unstable(feature = "ptr_internals", issue = "0")]
23462347
impl<T: ?Sized> fmt::Debug for Unique<T> {
23472348
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
23482349
write!(f, "{:p}", self.as_ptr())
@@ -2353,17 +2354,17 @@ impl<T: ?Sized> fmt::Debug for Unique<T> {
23532354
/// reference is unaliased. Note that this aliasing invariant is
23542355
/// unenforced by the type system; the abstraction using the
23552356
/// `Unique` must enforce it.
2356-
#[unstable(feature = "unique", issue = "27730")]
2357+
#[unstable(feature = "ptr_internals", issue = "0")]
23572358
unsafe impl<T: Send + ?Sized> Send for Unique<T> { }
23582359

23592360
/// `Unique` pointers are `Sync` if `T` is `Sync` because the data they
23602361
/// reference is unaliased. Note that this aliasing invariant is
23612362
/// unenforced by the type system; the abstraction using the
23622363
/// `Unique` must enforce it.
2363-
#[unstable(feature = "unique", issue = "27730")]
2364+
#[unstable(feature = "ptr_internals", issue = "0")]
23642365
unsafe impl<T: Sync + ?Sized> Sync for Unique<T> { }
23652366

2366-
#[unstable(feature = "unique", issue = "27730")]
2367+
#[unstable(feature = "ptr_internals", issue = "0")]
23672368
impl<T: Sized> Unique<T> {
23682369
/// Creates a new `Unique` that is dangling, but well-aligned.
23692370
///
@@ -2377,14 +2378,13 @@ impl<T: Sized> Unique<T> {
23772378
}
23782379
}
23792380

2380-
#[unstable(feature = "unique", issue = "27730")]
2381+
#[unstable(feature = "ptr_internals", issue = "0")]
23812382
impl<T: ?Sized> Unique<T> {
23822383
/// Creates a new `Unique`.
23832384
///
23842385
/// # Safety
23852386
///
23862387
/// `ptr` must be non-null.
2387-
#[unstable(feature = "unique", issue = "27730")]
23882388
pub const unsafe fn new_unchecked(ptr: *mut T) -> Self {
23892389
Unique { pointer: NonZero::new_unchecked(ptr), _marker: PhantomData }
23902390
}
@@ -2418,41 +2418,41 @@ impl<T: ?Sized> Unique<T> {
24182418
}
24192419
}
24202420

2421-
#[unstable(feature = "unique", issue = "27730")]
2421+
#[unstable(feature = "ptr_internals", issue = "0")]
24222422
impl<T: ?Sized> Clone for Unique<T> {
24232423
fn clone(&self) -> Self {
24242424
*self
24252425
}
24262426
}
24272427

2428-
#[unstable(feature = "unique", issue = "27730")]
2428+
#[unstable(feature = "ptr_internals", issue = "0")]
24292429
impl<T: ?Sized> Copy for Unique<T> { }
24302430

2431-
#[unstable(feature = "unique", issue = "27730")]
2431+
#[unstable(feature = "ptr_internals", issue = "0")]
24322432
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> { }
24332433

2434-
#[unstable(feature = "unique", issue = "27730")]
2434+
#[unstable(feature = "ptr_internals", issue = "0")]
24352435
impl<T: ?Sized> fmt::Pointer for Unique<T> {
24362436
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
24372437
fmt::Pointer::fmt(&self.as_ptr(), f)
24382438
}
24392439
}
24402440

2441-
#[unstable(feature = "unique", issue = "27730")]
2441+
#[unstable(feature = "ptr_internals", issue = "0")]
24422442
impl<'a, T: ?Sized> From<&'a mut T> for Unique<T> {
24432443
fn from(reference: &'a mut T) -> Self {
24442444
Unique { pointer: NonZero::from(reference), _marker: PhantomData }
24452445
}
24462446
}
24472447

2448-
#[unstable(feature = "unique", issue = "27730")]
2448+
#[unstable(feature = "ptr_internals", issue = "0")]
24492449
impl<'a, T: ?Sized> From<&'a T> for Unique<T> {
24502450
fn from(reference: &'a T) -> Self {
24512451
Unique { pointer: NonZero::from(reference), _marker: PhantomData }
24522452
}
24532453
}
24542454

2455-
#[unstable(feature = "unique", issue = "27730")]
2455+
#[unstable(feature = "ptr_internals", issue = "0")]
24562456
impl<'a, T: ?Sized> From<NonNull<T>> for Unique<T> {
24572457
fn from(p: NonNull<T>) -> Self {
24582458
Unique { pointer: p.pointer, _marker: PhantomData }

src/libcore/tests/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#![feature(iterator_try_fold)]
2828
#![feature(iter_rfind)]
2929
#![feature(iter_rfold)]
30+
#![feature(nonnull)]
3031
#![feature(nonzero)]
3132
#![feature(pattern)]
3233
#![feature(raw)]
@@ -41,7 +42,6 @@
4142
#![feature(trusted_len)]
4243
#![feature(try_from)]
4344
#![feature(try_trait)]
44-
#![feature(unique)]
4545
#![feature(exact_chunks)]
4646

4747
extern crate core;

src/libcore/tests/ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ fn test_set_memory() {
249249
}
250250

251251
#[test]
252-
fn test_unsized_unique() {
252+
fn test_unsized_nonnull() {
253253
let xs: &[i32] = &[1, 2, 3];
254-
let ptr = unsafe { Unique::new_unchecked(xs as *const [i32] as *mut [i32]) };
254+
let ptr = unsafe { NonNull::new_unchecked(xs as *const [i32] as *mut [i32]) };
255255
let ys = unsafe { ptr.as_ref() };
256256
let zs: &[i32] = &[1, 2, 3];
257257
assert!(ys == zs);

src/libstd/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@
294294
#![feature(placement_in_syntax)]
295295
#![feature(placement_new_protocol)]
296296
#![feature(prelude_import)]
297+
#![feature(ptr_internals)]
297298
#![feature(rand)]
298299
#![feature(raw)]
299300
#![feature(repr_align)]
@@ -315,7 +316,6 @@
315316
#![feature(try_from)]
316317
#![feature(unboxed_closures)]
317318
#![feature(unicode)]
318-
#![feature(unique)]
319319
#![feature(untagged_unions)]
320320
#![feature(unwind_attributes)]
321321
#![feature(vec_push_all)]

src/libstd/panic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl<'a, T: RefUnwindSafe + ?Sized> UnwindSafe for &'a T {}
196196
impl<T: RefUnwindSafe + ?Sized> UnwindSafe for *const T {}
197197
#[stable(feature = "catch_unwind", since = "1.9.0")]
198198
impl<T: RefUnwindSafe + ?Sized> UnwindSafe for *mut T {}
199-
#[unstable(feature = "unique", issue = "27730")]
199+
#[unstable(feature = "ptr_internals", issue = "0")]
200200
impl<T: UnwindSafe + ?Sized> UnwindSafe for Unique<T> {}
201201
#[unstable(feature = "nonnull", issue = "27730")]
202202
impl<T: RefUnwindSafe + ?Sized> UnwindSafe for NonNull<T> {}

src/test/run-pass/issue-23433.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
// Don't fail if we encounter a NonZero<*T> where T is an unsized type
1212

13-
#![feature(unique)]
13+
#![feature(nonnull)]
1414

15-
use std::ptr::Unique;
15+
use std::ptr::NonNull;
1616

1717
fn main() {
1818
let mut a = [0u8; 5];
19-
let b: Option<Unique<[u8]>> = Some(Unique::from(&mut a));
19+
let b: Option<NonNull<[u8]>> = Some(NonNull::from(&mut a));
2020
match b {
2121
Some(_) => println!("Got `Some`"),
2222
None => panic!("Unexpected `None`"),

0 commit comments

Comments
 (0)