diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2018-12-23 23:09:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-23 23:09:04 +0100 |
| commit | 93af1e73696c82de22eb445423f10df35130dded (patch) | |
| tree | deaa2f71918324d93ea6196f7fc4834bff83ec16 /src/liballoc | |
| parent | 6ce5ecbc2a6c7e323f8194229327c179cb7d976d (diff) | |
| parent | 861df06e077bb17c2d22ab978e37ee2c5350ff9b (diff) | |
| download | rust-93af1e73696c82de22eb445423f10df35130dded.tar.gz rust-93af1e73696c82de22eb445423f10df35130dded.zip | |
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
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/boxed.rs | 10 | ||||
| -rw-r--r-- | src/liballoc/lib.rs | 1 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 8 | ||||
| -rw-r--r-- | src/liballoc/sync.rs | 8 |
4 files changed, 16 insertions, 11 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index f1581310b48..7438f3e6c9d 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -111,9 +111,11 @@ impl<T> Box<T> { 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)] - pub fn pinned(x: T) -> Pin<Box<T>> { + pub fn pin(x: T) -> Pin<Box<T>> { (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>> { fn from(boxed: Box<T>) -> Self { // 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 * 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> { } #[unstable(feature = "generator_trait", issue = "43122")] diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index afa7a6f919d..8a66cafc001 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -102,7 +102,6 @@ #![feature(nll)] #![feature(optin_builtin_traits)] #![feature(pattern)] -#![feature(pin)] #![feature(ptr_internals)] #![feature(ptr_offset_from)] #![feature(rustc_attrs)] diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 65a610b9d1e..af316b0b61b 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -325,8 +325,10 @@ impl<T> Rc<T> { } } - #[unstable(feature = "pin", issue = "49150")] - pub fn pinned(value: T) -> Pin<Rc<T>> { + /// Constructs a new `Pin<Rc<T>>`. If `T` does not implement `Unpin`, then + /// `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)) } } @@ -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> { } diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 948c36117a3..7b8afb1943c 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -303,8 +303,10 @@ impl<T> Arc<T> { Arc { ptr: Box::into_raw_non_null(x), phantom: PhantomData } } - #[unstable(feature = "pin", issue = "49150")] - pub fn pinned(data: T) -> Pin<Arc<T>> { + /// Constructs a new `Pin<Arc<T>>`. If `T` does not implement `Unpin`, then + /// `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)) } } @@ -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> { } |
