1
Fork 0

Rollup merge of #56939 - cramertj:pin-stabilization, r=alexcrichton

Pin stabilization

This implements the changes suggested in https://github.com/rust-lang/rust/issues/55766#issue-378417538 and stabilizes the `pin` feature. @alexcrichton also listed several "blockers" in that issue, but then in [this comment](https://github.com/rust-lang/rust/issues/55766#issuecomment-445074980) mentioned that they're more "TODO items":
>  In that vein I think it's fine for a stabilization PR to be posted at any time now with FCP lapsed for a week or so now. The final points about self/pin/pinned can be briefly discussed there (if even necessary, they could be left as the proposal above).

Let's settle these last bits here and get this thing stabilized! :)

r? @alexcrichton
cc @withoutboats
This commit is contained in:
Mazdak Farrokhzad 2018-12-23 23:09:04 +01:00 committed by GitHub
commit 93af1e7369
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 70 additions and 74 deletions

View file

@ -111,9 +111,11 @@ impl<T> Box<T> {
box x box x
} }
#[unstable(feature = "pin", issue = "49150")] /// Constructs a new `Pin<Box<T>>`. If `T` does not implement `Unpin`, then
/// `x` will be pinned in memory and unable to be moved.
#[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub fn pinned(x: T) -> Pin<Box<T>> { pub fn pin(x: T) -> Pin<Box<T>> {
(box x).into() (box x).into()
} }
} }
@ -446,7 +448,7 @@ impl<T> From<T> for Box<T> {
} }
} }
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
impl<T> From<Box<T>> for Pin<Box<T>> { impl<T> From<Box<T>> for Pin<Box<T>> {
fn from(boxed: Box<T>) -> Self { fn from(boxed: Box<T>) -> Self {
// It's not possible to move or replace the insides of a `Pin<Box<T>>` // It's not possible to move or replace the insides of a `Pin<Box<T>>`
@ -813,7 +815,7 @@ impl<T: ?Sized> AsMut<T> for Box<T> {
* implementation of `Unpin` (where `T: Unpin`) would be valid/safe, and * implementation of `Unpin` (where `T: Unpin`) would be valid/safe, and
* could have a method to project a Pin<T> from it. * could have a method to project a Pin<T> from it.
*/ */
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
impl<T: ?Sized> Unpin for Box<T> { } impl<T: ?Sized> Unpin for Box<T> { }
#[unstable(feature = "generator_trait", issue = "43122")] #[unstable(feature = "generator_trait", issue = "43122")]

View file

@ -102,7 +102,6 @@
#![feature(nll)] #![feature(nll)]
#![feature(optin_builtin_traits)] #![feature(optin_builtin_traits)]
#![feature(pattern)] #![feature(pattern)]
#![feature(pin)]
#![feature(ptr_internals)] #![feature(ptr_internals)]
#![feature(ptr_offset_from)] #![feature(ptr_offset_from)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]

View file

@ -325,8 +325,10 @@ impl<T> Rc<T> {
} }
} }
#[unstable(feature = "pin", issue = "49150")] /// Constructs a new `Pin<Rc<T>>`. If `T` does not implement `Unpin`, then
pub fn pinned(value: T) -> Pin<Rc<T>> { /// `value` will be pinned in memory and unable to be moved.
#[stable(feature = "pin", since = "1.33.0")]
pub fn pin(value: T) -> Pin<Rc<T>> {
unsafe { Pin::new_unchecked(Rc::new(value)) } unsafe { Pin::new_unchecked(Rc::new(value)) }
} }
@ -1934,5 +1936,5 @@ impl<T: ?Sized> AsRef<T> for Rc<T> {
} }
} }
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
impl<T: ?Sized> Unpin for Rc<T> { } impl<T: ?Sized> Unpin for Rc<T> { }

View file

@ -303,8 +303,10 @@ impl<T> Arc<T> {
Arc { ptr: Box::into_raw_non_null(x), phantom: PhantomData } Arc { ptr: Box::into_raw_non_null(x), phantom: PhantomData }
} }
#[unstable(feature = "pin", issue = "49150")] /// Constructs a new `Pin<Arc<T>>`. If `T` does not implement `Unpin`, then
pub fn pinned(data: T) -> Pin<Arc<T>> { /// `data` will be pinned in memory and unable to be moved.
#[stable(feature = "pin", since = "1.33.0")]
pub fn pin(data: T) -> Pin<Arc<T>> {
unsafe { Pin::new_unchecked(Arc::new(data)) } unsafe { Pin::new_unchecked(Arc::new(data)) }
} }
@ -2050,5 +2052,5 @@ impl<T: ?Sized> AsRef<T> for Arc<T> {
} }
} }
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
impl<T: ?Sized> Unpin for Arc<T> { } impl<T: ?Sized> Unpin for Arc<T> { }

View file

@ -120,7 +120,7 @@ impl<'a, F: ?Sized + Future + Unpin> Future for &'a mut F {
impl<P> Future for Pin<P> impl<P> Future for Pin<P>
where where
P: ops::DerefMut, P: Unpin + ops::DerefMut,
P::Target: Future, P::Target: Future,
{ {
type Output = <<P as ops::Deref>::Target as Future>::Output; type Output = <<P as ops::Deref>::Target as Future>::Output;

View file

@ -621,7 +621,6 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
/// So this, for example, can only be done on types implementing `Unpin`: /// So this, for example, can only be done on types implementing `Unpin`:
/// ///
/// ```rust /// ```rust
/// #![feature(pin)]
/// use std::mem::replace; /// use std::mem::replace;
/// use std::pin::Pin; /// use std::pin::Pin;
/// ///
@ -637,23 +636,23 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
/// [`replace`]: ../../std/mem/fn.replace.html /// [`replace`]: ../../std/mem/fn.replace.html
/// [`Pin`]: ../pin/struct.Pin.html /// [`Pin`]: ../pin/struct.Pin.html
/// [`pin module`]: ../../std/pin/index.html /// [`pin module`]: ../../std/pin/index.html
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
pub auto trait Unpin {} pub auto trait Unpin {}
/// A marker type which does not implement `Unpin`. /// A marker type which does not implement `Unpin`.
/// ///
/// If a type contains a `PhantomPinned`, it will not implement `Unpin` by default. /// If a type contains a `PhantomPinned`, it will not implement `Unpin` by default.
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct PhantomPinned; pub struct PhantomPinned;
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
impl !Unpin for PhantomPinned {} impl !Unpin for PhantomPinned {}
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
impl<'a, T: ?Sized + 'a> Unpin for &'a T {} impl<'a, T: ?Sized + 'a> Unpin for &'a T {}
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
impl<'a, T: ?Sized + 'a> Unpin for &'a mut T {} impl<'a, T: ?Sized + 'a> Unpin for &'a mut T {}
/// Implementations of `Copy` for primitive types. /// Implementations of `Copy` for primitive types.

View file

@ -273,7 +273,7 @@ impl<T> Option<T> {
/// Converts from `Pin<&Option<T>>` to `Option<Pin<&T>>` /// Converts from `Pin<&Option<T>>` to `Option<Pin<&T>>`
#[inline] #[inline]
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
pub fn as_pin_ref<'a>(self: Pin<&'a Option<T>>) -> Option<Pin<&'a T>> { pub fn as_pin_ref<'a>(self: Pin<&'a Option<T>>) -> Option<Pin<&'a T>> {
unsafe { unsafe {
Pin::get_ref(self).as_ref().map(|x| Pin::new_unchecked(x)) Pin::get_ref(self).as_ref().map(|x| Pin::new_unchecked(x))
@ -282,10 +282,10 @@ impl<T> Option<T> {
/// Converts from `Pin<&mut Option<T>>` to `Option<Pin<&mut T>>` /// Converts from `Pin<&mut Option<T>>` to `Option<Pin<&mut T>>`
#[inline] #[inline]
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
pub fn as_pin_mut<'a>(self: Pin<&'a mut Option<T>>) -> Option<Pin<&'a mut T>> { pub fn as_pin_mut<'a>(self: Pin<&'a mut Option<T>>) -> Option<Pin<&'a mut T>> {
unsafe { unsafe {
Pin::get_mut_unchecked(self).as_mut().map(|x| Pin::new_unchecked(x)) Pin::get_unchecked_mut(self).as_mut().map(|x| Pin::new_unchecked(x))
} }
} }

View file

@ -36,15 +36,13 @@
//! are always freely movable, even if the data they point to isn't. //! are always freely movable, even if the data they point to isn't.
//! //!
//! [`Pin`]: struct.Pin.html //! [`Pin`]: struct.Pin.html
//! [`Unpin`]: trait.Unpin.html //! [`Unpin`]: ../../std/marker/trait.Unpin.html
//! [`swap`]: ../../std/mem/fn.swap.html //! [`swap`]: ../../std/mem/fn.swap.html
//! [`Box`]: ../../std/boxed/struct.Box.html //! [`Box`]: ../../std/boxed/struct.Box.html
//! //!
//! # Examples //! # Examples
//! //!
//! ```rust //! ```rust
//! #![feature(pin)]
//!
//! use std::pin::Pin; //! use std::pin::Pin;
//! use std::marker::PhantomPinned; //! use std::marker::PhantomPinned;
//! use std::ptr::NonNull; //! use std::ptr::NonNull;
@ -72,13 +70,13 @@
//! slice: NonNull::dangling(), //! slice: NonNull::dangling(),
//! _pin: PhantomPinned, //! _pin: PhantomPinned,
//! }; //! };
//! let mut boxed = Box::pinned(res); //! let mut boxed = Box::pin(res);
//! //!
//! let slice = NonNull::from(&boxed.data); //! let slice = NonNull::from(&boxed.data);
//! // we know this is safe because modifying a field doesn't move the whole struct //! // we know this is safe because modifying a field doesn't move the whole struct
//! unsafe { //! unsafe {
//! let mut_ref: Pin<&mut Self> = Pin::as_mut(&mut boxed); //! let mut_ref: Pin<&mut Self> = Pin::as_mut(&mut boxed);
//! Pin::get_mut_unchecked(mut_ref).slice = slice; //! Pin::get_unchecked_mut(mut_ref).slice = slice;
//! } //! }
//! boxed //! boxed
//! } //! }
@ -97,15 +95,12 @@
//! // std::mem::swap(&mut *still_unmoved, &mut *new_unmoved); //! // std::mem::swap(&mut *still_unmoved, &mut *new_unmoved);
//! ``` //! ```
#![unstable(feature = "pin", issue = "49150")] #![stable(feature = "pin", since = "1.33.0")]
use fmt; use fmt;
use marker::Sized; use marker::{Sized, Unpin};
use ops::{Deref, DerefMut, Receiver, CoerceUnsized, DispatchFromDyn}; use ops::{Deref, DerefMut, Receiver, CoerceUnsized, DispatchFromDyn};
#[doc(inline)]
pub use marker::Unpin;
/// A pinned pointer. /// A pinned pointer.
/// ///
/// This is a wrapper around a kind of pointer which makes that pointer "pin" its /// This is a wrapper around a kind of pointer which makes that pointer "pin" its
@ -119,8 +114,9 @@ pub use marker::Unpin;
// //
// Note: the derives below are allowed because they all only use `&P`, so they // Note: the derives below are allowed because they all only use `&P`, so they
// cannot move the value behind `pointer`. // cannot move the value behind `pointer`.
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
#[fundamental] #[fundamental]
#[repr(transparent)]
#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)] #[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct Pin<P> { pub struct Pin<P> {
pointer: P, pointer: P,
@ -132,7 +128,7 @@ where
{ {
/// Construct a new `Pin` around a pointer to some data of a type that /// Construct a new `Pin` around a pointer to some data of a type that
/// implements `Unpin`. /// implements `Unpin`.
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub fn new(pointer: P) -> Pin<P> { pub fn new(pointer: P) -> Pin<P> {
// Safety: the value pointed to is `Unpin`, and so has no requirements // Safety: the value pointed to is `Unpin`, and so has no requirements
@ -154,14 +150,14 @@ impl<P: Deref> Pin<P> {
/// ///
/// If `pointer` dereferences to an `Unpin` type, `Pin::new` should be used /// If `pointer` dereferences to an `Unpin` type, `Pin::new` should be used
/// instead. /// instead.
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub unsafe fn new_unchecked(pointer: P) -> Pin<P> { pub unsafe fn new_unchecked(pointer: P) -> Pin<P> {
Pin { pointer } Pin { pointer }
} }
/// Get a pinned shared reference from this pinned pointer. /// Get a pinned shared reference from this pinned pointer.
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub fn as_ref(self: &Pin<P>) -> Pin<&P::Target> { pub fn as_ref(self: &Pin<P>) -> Pin<&P::Target> {
unsafe { Pin::new_unchecked(&*self.pointer) } unsafe { Pin::new_unchecked(&*self.pointer) }
@ -170,14 +166,14 @@ impl<P: Deref> Pin<P> {
impl<P: DerefMut> Pin<P> { impl<P: DerefMut> Pin<P> {
/// Get a pinned mutable reference from this pinned pointer. /// Get a pinned mutable reference from this pinned pointer.
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub fn as_mut(self: &mut Pin<P>) -> Pin<&mut P::Target> { pub fn as_mut(self: &mut Pin<P>) -> Pin<&mut P::Target> {
unsafe { Pin::new_unchecked(&mut *self.pointer) } unsafe { Pin::new_unchecked(&mut *self.pointer) }
} }
/// Assign a new value to the memory behind the pinned reference. /// Assign a new value to the memory behind the pinned reference.
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub fn set(mut self: Pin<P>, value: P::Target) pub fn set(mut self: Pin<P>, value: P::Target)
where where
@ -199,11 +195,11 @@ impl<'a, T: ?Sized> Pin<&'a T> {
/// will not move so long as the argument value does not move (for example, /// will not move so long as the argument value does not move (for example,
/// because it is one of the fields of that value), and also that you do /// because it is one of the fields of that value), and also that you do
/// not move out of the argument you receive to the interior function. /// not move out of the argument you receive to the interior function.
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
pub unsafe fn map_unchecked<U, F>(this: Pin<&'a T>, func: F) -> Pin<&'a U> where pub unsafe fn map_unchecked<U, F>(self: Pin<&'a T>, func: F) -> Pin<&'a U> where
F: FnOnce(&T) -> &U, F: FnOnce(&T) -> &U,
{ {
let pointer = &*this.pointer; let pointer = &*self.pointer;
let new_pointer = func(pointer); let new_pointer = func(pointer);
Pin::new_unchecked(new_pointer) Pin::new_unchecked(new_pointer)
} }
@ -215,19 +211,19 @@ impl<'a, T: ?Sized> Pin<&'a T> {
/// that lives for as long as the borrow of the `Pin`, not the lifetime of /// that lives for as long as the borrow of the `Pin`, not the lifetime of
/// the `Pin` itself. This method allows turning the `Pin` into a reference /// the `Pin` itself. This method allows turning the `Pin` into a reference
/// with the same lifetime as the original `Pin`. /// with the same lifetime as the original `Pin`.
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub fn get_ref(this: Pin<&'a T>) -> &'a T { pub fn get_ref(self: Pin<&'a T>) -> &'a T {
this.pointer self.pointer
} }
} }
impl<'a, T: ?Sized> Pin<&'a mut T> { impl<'a, T: ?Sized> Pin<&'a mut T> {
/// Convert this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime. /// Convert this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime.
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub fn into_ref(this: Pin<&'a mut T>) -> Pin<&'a T> { pub fn into_ref(self: Pin<&'a mut T>) -> Pin<&'a T> {
Pin { pointer: this.pointer } Pin { pointer: self.pointer }
} }
/// Get a mutable reference to the data inside of this `Pin`. /// Get a mutable reference to the data inside of this `Pin`.
@ -239,12 +235,12 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
/// that lives for as long as the borrow of the `Pin`, not the lifetime of /// that lives for as long as the borrow of the `Pin`, not the lifetime of
/// the `Pin` itself. This method allows turning the `Pin` into a reference /// the `Pin` itself. This method allows turning the `Pin` into a reference
/// with the same lifetime as the original `Pin`. /// with the same lifetime as the original `Pin`.
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub fn get_mut(this: Pin<&'a mut T>) -> &'a mut T pub fn get_mut(self: Pin<&'a mut T>) -> &'a mut T
where T: Unpin, where T: Unpin,
{ {
this.pointer self.pointer
} }
/// Get a mutable reference to the data inside of this `Pin`. /// Get a mutable reference to the data inside of this `Pin`.
@ -257,10 +253,10 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
/// ///
/// If the underlying data is `Unpin`, `Pin::get_mut` should be used /// If the underlying data is `Unpin`, `Pin::get_mut` should be used
/// instead. /// instead.
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
#[inline(always)] #[inline(always)]
pub unsafe fn get_mut_unchecked(this: Pin<&'a mut T>) -> &'a mut T { pub unsafe fn get_unchecked_mut(self: Pin<&'a mut T>) -> &'a mut T {
this.pointer self.pointer
} }
/// Construct a new pin by mapping the interior value. /// Construct a new pin by mapping the interior value.
@ -274,17 +270,17 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
/// will not move so long as the argument value does not move (for example, /// will not move so long as the argument value does not move (for example,
/// because it is one of the fields of that value), and also that you do /// because it is one of the fields of that value), and also that you do
/// not move out of the argument you receive to the interior function. /// not move out of the argument you receive to the interior function.
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
pub unsafe fn map_unchecked_mut<U, F>(this: Pin<&'a mut T>, func: F) -> Pin<&'a mut U> where pub unsafe fn map_unchecked_mut<U, F>(self: Pin<&'a mut T>, func: F) -> Pin<&'a mut U> where
F: FnOnce(&mut T) -> &mut U, F: FnOnce(&mut T) -> &mut U,
{ {
let pointer = Pin::get_mut_unchecked(this); let pointer = Pin::get_unchecked_mut(self);
let new_pointer = func(pointer); let new_pointer = func(pointer);
Pin::new_unchecked(new_pointer) Pin::new_unchecked(new_pointer)
} }
} }
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
impl<P: Deref> Deref for Pin<P> { impl<P: Deref> Deref for Pin<P> {
type Target = P::Target; type Target = P::Target;
fn deref(&self) -> &P::Target { fn deref(&self) -> &P::Target {
@ -292,7 +288,7 @@ impl<P: Deref> Deref for Pin<P> {
} }
} }
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
impl<P: DerefMut> DerefMut for Pin<P> impl<P: DerefMut> DerefMut for Pin<P>
where where
P::Target: Unpin P::Target: Unpin
@ -305,21 +301,21 @@ where
#[unstable(feature = "receiver_trait", issue = "0")] #[unstable(feature = "receiver_trait", issue = "0")]
impl<P: Receiver> Receiver for Pin<P> {} impl<P: Receiver> Receiver for Pin<P> {}
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
impl<P: fmt::Debug> fmt::Debug for Pin<P> { impl<P: fmt::Debug> fmt::Debug for Pin<P> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.pointer, f) fmt::Debug::fmt(&self.pointer, f)
} }
} }
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
impl<P: fmt::Display> fmt::Display for Pin<P> { impl<P: fmt::Display> fmt::Display for Pin<P> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.pointer, f) fmt::Display::fmt(&self.pointer, f)
} }
} }
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
impl<P: fmt::Pointer> fmt::Pointer for Pin<P> { impl<P: fmt::Pointer> fmt::Pointer for Pin<P> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Pointer::fmt(&self.pointer, f) fmt::Pointer::fmt(&self.pointer, f)
@ -331,17 +327,14 @@ impl<P: fmt::Pointer> fmt::Pointer for Pin<P> {
// `Deref<Target=Unpin>` is unsound. Any such impl would probably be unsound // `Deref<Target=Unpin>` is unsound. Any such impl would probably be unsound
// for other reasons, though, so we just need to take care not to allow such // for other reasons, though, so we just need to take care not to allow such
// impls to land in std. // impls to land in std.
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
impl<P, U> CoerceUnsized<Pin<U>> for Pin<P> impl<P, U> CoerceUnsized<Pin<U>> for Pin<P>
where where
P: CoerceUnsized<U>, P: CoerceUnsized<U>,
{} {}
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
impl<'a, P, U> DispatchFromDyn<Pin<U>> for Pin<P> impl<'a, P, U> DispatchFromDyn<Pin<U>> for Pin<P>
where where
P: DispatchFromDyn<U>, P: DispatchFromDyn<U>,
{} {}
#[unstable(feature = "pin", issue = "49150")]
impl<P> Unpin for Pin<P> {}

View file

@ -19,7 +19,7 @@
// Re-exported core operators // Re-exported core operators
#[stable(feature = "core_prelude", since = "1.4.0")] #[stable(feature = "core_prelude", since = "1.4.0")]
#[doc(no_inline)] #[doc(no_inline)]
pub use marker::{Copy, Send, Sized, Sync}; pub use marker::{Copy, Send, Sized, Sync, Unpin};
#[stable(feature = "core_prelude", since = "1.4.0")] #[stable(feature = "core_prelude", since = "1.4.0")]
#[doc(no_inline)] #[doc(no_inline)]
pub use ops::{Drop, Fn, FnMut, FnOnce}; pub use ops::{Drop, Fn, FnMut, FnOnce};

View file

@ -43,7 +43,7 @@ impl<T: Generator<Yield = ()>> !Unpin for GenFuture<T> {}
impl<T: Generator<Yield = ()>> Future for GenFuture<T> { impl<T: Generator<Yield = ()>> Future for GenFuture<T> {
type Output = T::Return; type Output = T::Return;
fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Self::Output> { fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Self::Output> {
set_task_waker(lw, || match unsafe { Pin::get_mut_unchecked(self).0.resume() } { set_task_waker(lw, || match unsafe { Pin::get_unchecked_mut(self).0.resume() } {
GeneratorState::Yielded(()) => Poll::Pending, GeneratorState::Yielded(()) => Poll::Pending,
GeneratorState::Complete(x) => Poll::Ready(x), GeneratorState::Complete(x) => Poll::Ready(x),
}) })

View file

@ -282,7 +282,6 @@
#![feature(optin_builtin_traits)] #![feature(optin_builtin_traits)]
#![feature(panic_internals)] #![feature(panic_internals)]
#![feature(panic_unwind)] #![feature(panic_unwind)]
#![feature(pin)]
#![feature(prelude_import)] #![feature(prelude_import)]
#![feature(ptr_internals)] #![feature(ptr_internals)]
#![feature(raw)] #![feature(raw)]
@ -434,7 +433,7 @@ pub use alloc_crate::borrow;
pub use alloc_crate::fmt; pub use alloc_crate::fmt;
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub use alloc_crate::format; pub use alloc_crate::format;
#[unstable(feature = "pin", issue = "49150")] #[stable(feature = "pin", since = "1.33.0")]
pub use core::pin; pub use core::pin;
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub use alloc_crate::slice; pub use alloc_crate::slice;

View file

@ -1,5 +1,5 @@
#![deny(unused_must_use)] #![deny(unused_must_use)]
#![feature(futures_api, pin, arbitrary_self_types)] #![feature(arbitrary_self_types, futures_api)]
use std::iter::Iterator; use std::iter::Iterator;
use std::future::Future; use std::future::Future;

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![feature(pin)] #![feature(arbitrary_self_types)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
use std::{ use std::{

View file

@ -10,7 +10,7 @@
// edition:2018 // edition:2018
#![feature(arbitrary_self_types, async_await, await_macro, futures_api, pin)] #![feature(arbitrary_self_types, async_await, await_macro, futures_api)]
use std::pin::Pin; use std::pin::Pin;
use std::future::Future; use std::future::Future;
@ -138,7 +138,7 @@ where
F: FnOnce(u8) -> Fut, F: FnOnce(u8) -> Fut,
Fut: Future<Output = u8>, Fut: Future<Output = u8>,
{ {
let mut fut = Box::pinned(f(9)); let mut fut = Box::pin(f(9));
let counter = Arc::new(Counter { wakes: AtomicUsize::new(0) }); let counter = Arc::new(Counter { wakes: AtomicUsize::new(0) });
let waker = local_waker_from_nonlocal(counter.clone()); let waker = local_waker_from_nonlocal(counter.clone());
assert_eq!(0, counter.wakes.load(atomic::Ordering::SeqCst)); assert_eq!(0, counter.wakes.load(atomic::Ordering::SeqCst));

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![feature(arbitrary_self_types, futures_api, pin)] #![feature(arbitrary_self_types, futures_api)]
#![allow(unused)] #![allow(unused)]
use std::future::Future; use std::future::Future;