diff --git a/futures-async-runtime/src/future.rs b/futures-async-runtime/src/future.rs index 712af91721..d2a954789a 100644 --- a/futures-async-runtime/src/future.rs +++ b/futures-async-runtime/src/future.rs @@ -1,5 +1,5 @@ use std::marker::Unpin; -use std::mem::Pin; +use std::mem::PinMut; use std::ops::{Generator, GeneratorState}; use super::{IsResult, Reset, CTX}; @@ -25,12 +25,12 @@ impl StableFuture for GenStableFuture type Item = ::Ok; type Error = ::Err; - fn poll(mut self: Pin, ctx: &mut task::Context) -> Poll { + fn poll(self: PinMut, ctx: &mut task::Context) -> Poll { CTX.with(|cell| { let _r = Reset::new(ctx, cell); - let this: &mut Self = unsafe { Pin::get_mut(&mut self) }; + let this: &mut Self = unsafe { PinMut::get_mut(self) }; // This is an immovable generator, but since we're only accessing - // it via a Pin this is safe. + // it via a PinMut this is safe. match unsafe { this.0.resume() } { GeneratorState::Yielded(Async::Pending) => Ok(Async::Pending), diff --git a/futures-async-runtime/src/stream.rs b/futures-async-runtime/src/stream.rs index ed82f481fa..5db4dfe39d 100644 --- a/futures-async-runtime/src/stream.rs +++ b/futures-async-runtime/src/stream.rs @@ -1,4 +1,4 @@ -use std::mem::Pin; +use std::mem::PinMut; use std::ops::{Generator, GeneratorState}; use std::marker::{PhantomData, Unpin}; @@ -37,13 +37,13 @@ impl StableStream for GenStableStream type Item = U; type Error = ::Err; - fn poll_next(mut self: Pin, ctx: &mut task::Context) -> Poll, Self::Error> { + fn poll_next(self: PinMut, ctx: &mut task::Context) -> Poll, Self::Error> { CTX.with(|cell| { let _r = Reset::new(ctx, cell); - let this: &mut Self = unsafe { Pin::get_mut(&mut self) }; + let this: &mut Self = unsafe { PinMut::get_mut(self) }; if this.done { return Ok(Async::Ready(None)) } // This is an immovable generator, but since we're only accessing - // it via a Pin this is safe. + // it via a PinMut this is safe. match unsafe { this.gen.resume() } { GeneratorState::Yielded(Async::Ready(e)) => { Ok(Async::Ready(Some(e))) diff --git a/futures-channel/src/mpsc/mod.rs b/futures-channel/src/mpsc/mod.rs index b96eba69e4..5d75f35df3 100644 --- a/futures-channel/src/mpsc/mod.rs +++ b/futures-channel/src/mpsc/mod.rs @@ -3,7 +3,7 @@ //! //! Similarly to the `std`, channel creation provides [`Receiver`](Receiver) and //! [`Sender`](Sender) handles. [`Receiver`](Receiver) implements -//! [`Stream`](futures_core::Stream) and allows a task to read values out of the +//! [`Stream`] and allows a task to read values out of the //! channel. If there is no message to read from the channel, the current task //! will be awoken when a new value is sent. [`Sender`](Sender) implements the //! `Sink` trait and allows a task to send messages into @@ -333,7 +333,7 @@ impl SenderWaker { /// `buffer` "first come, first serve" slots available to all senders. /// /// The [`Receiver`](Receiver) returned implements the -/// [`Stream`](futures_core::Stream) trait, while [`Sender`](Sender) implements +/// [`Stream`] trait, while [`Sender`](Sender) implements /// `Sink`. pub fn channel(buffer: usize) -> (Sender, Receiver) { // Check that the requested buffer size does not exceed the maximum buffer diff --git a/futures-core/src/future/mod.rs b/futures-core/src/future/mod.rs index f722944ebd..b749f197a8 100644 --- a/futures-core/src/future/mod.rs +++ b/futures-core/src/future/mod.rs @@ -147,7 +147,7 @@ if_std! { type Error = F::Error; fn poll(&mut self, cx: &mut task::Context) -> Poll { - unsafe { ::core::mem::Pin::get_mut(&mut self.as_pin()).poll(cx) } + unsafe { ::core::mem::PinMut::get_mut(self.as_pin_mut()).poll(cx) } } } diff --git a/futures-core/src/stream/mod.rs b/futures-core/src/stream/mod.rs index 9592b02d03..e095163e47 100644 --- a/futures-core/src/stream/mod.rs +++ b/futures-core/src/stream/mod.rs @@ -89,7 +89,7 @@ if_std! { type Error = S::Error; fn poll_next(&mut self, cx: &mut task::Context) -> Poll, Self::Error> { - unsafe { ::core::mem::Pin::get_mut(&mut self.as_pin()).poll_next(cx) } + unsafe { ::core::mem::PinMut::get_mut(self.as_pin_mut()).poll_next(cx) } } } diff --git a/futures-macro-async/src/lib.rs b/futures-macro-async/src/lib.rs index d0ab36094b..4d2e33e5ed 100644 --- a/futures-macro-async/src/lib.rs +++ b/futures-macro-async/src/lib.rs @@ -433,7 +433,7 @@ if_nightly! { let #pat = { let r = { let pin = unsafe { - ::futures::__rt::std::mem::Pin::new_unchecked(&mut __stream) + ::futures::__rt::std::mem::PinMut::new_unchecked(&mut __stream) }; ::futures::__rt::in_ctx(|ctx| ::futures::__rt::StableStream::poll_next(pin, ctx)) }; diff --git a/futures-macro-await/src/lib.rs b/futures-macro-await/src/lib.rs index ffef6d1b06..55cbfe5b02 100644 --- a/futures-macro-await/src/lib.rs +++ b/futures-macro-await/src/lib.rs @@ -39,12 +39,12 @@ macro_rules! await { let future = &mut future; // The above borrow is necessary to force a borrow across a // yield point, proving that we're currently in an immovable - // generator, making the below `Pin::new_unchecked` call + // generator, making the below `PinMut::new_unchecked` call // safe. loop { let poll = ::futures::__rt::in_ctx(|ctx| { let pin = unsafe { - ::futures::__rt::std::mem::Pin::new_unchecked(future) + ::futures::__rt::std::mem::PinMut::new_unchecked(future) }; ::futures::__rt::StableFuture::poll(pin, ctx) }); diff --git a/futures-stable/src/lib.rs b/futures-stable/src/lib.rs index 7760218a27..93ef306702 100644 --- a/futures-stable/src/lib.rs +++ b/futures-stable/src/lib.rs @@ -20,7 +20,7 @@ if_nightly! { extern crate futures_core; extern crate futures_executor; - use core::mem::Pin; + use core::mem::PinMut; use futures_core::{Future, Stream, Poll, task}; if_std! { @@ -37,7 +37,7 @@ if_nightly! { /// A trait for `Future`s which can be pinned to a particular location in memory. /// - /// These futures take `self` by `Pin`, rather than `&mut Self`. + /// These futures take `self` by `PinMut`, rather than `&mut Self`. /// This allows types which are not [`Unpin`](::std::marker::Unpin) to guarantee /// that they won't be moved after being polled. Since they won't be moved, it's /// possible for them to safely contain references to themselves. @@ -56,10 +56,10 @@ if_nightly! { /// Attempt to resolve the future to a final value, registering the current task /// for wakeup if the value is not yet available. /// - /// This method takes `self` by `Pin`, and so calling it requires putting `Self` + /// This method takes `self` by `PinMut`, and so calling it requires putting `Self` /// in a [`PinBox`](::std::boxed::PinBox) using the `pin` method, or otherwise /// guaranteeing that the location of `self` will not change after a call to `poll`. - fn poll(self: Pin, ctx: &mut task::Context) -> Poll; + fn poll(self: PinMut, ctx: &mut task::Context) -> Poll; /// Pin the future to a particular location by placing it on the heap. #[cfg(feature = "std")] @@ -85,14 +85,14 @@ if_nightly! { type Item = F::Item; type Error = F::Error; - fn poll(mut self: Pin, ctx: &mut task::Context) -> Poll { - F::poll(unsafe { Pin::get_mut(&mut self) }, ctx) + fn poll(self: PinMut, ctx: &mut task::Context) -> Poll { + F::poll(unsafe { PinMut::get_mut(self) }, ctx) } } /// A trait for `Stream`s which can be pinned to a particular location in memory. /// - /// These streams take `self` by `Pin`, rather than `&mut Self`. + /// These streams take `self` by `PinMut`, rather than `&mut Self`. /// This allows types which are not [`Unpin`](::std::marker::Unpin) to guarantee /// that they won't be moved after being polled. Since they won't be moved, it's /// possible for them to safely contain references to themselves. @@ -110,10 +110,10 @@ if_nightly! { /// Attempt to resolve the stream to the next value, registering the current task /// for wakeup if the value is not yet available. /// - /// This method takes `self` by `Pin`, and so calling it requires putting `Self` + /// This method takes `self` by `PinMut`, and so calling it requires putting `Self` /// in a [`PinBox`](::std::boxed::PinBox) using the `pin` method, or otherwise /// guaranteeing that the location of `self` will not change after a call to `poll`. - fn poll_next(self: Pin, ctx: &mut task::Context) -> Poll, Self::Error>; + fn poll_next(self: PinMut, ctx: &mut task::Context) -> Poll, Self::Error>; /// Pin the stream to a particular location by placing it on the heap. #[cfg(feature = "std")] @@ -139,8 +139,8 @@ if_nightly! { type Item = S::Item; type Error = S::Error; - fn poll_next(mut self: Pin, ctx: &mut task::Context) -> Poll, Self::Error> { - S::poll_next(unsafe { Pin::get_mut(&mut self) }, ctx) + fn poll_next(self: PinMut, ctx: &mut task::Context) -> Poll, Self::Error> { + S::poll_next(unsafe { PinMut::get_mut(self) }, ctx) } } } diff --git a/futures-stable/src/unsafe_pin.rs b/futures-stable/src/unsafe_pin.rs index 2640c704f6..bfbdecd272 100644 --- a/futures-stable/src/unsafe_pin.rs +++ b/futures-stable/src/unsafe_pin.rs @@ -1,4 +1,4 @@ -use core::mem::Pin; +use core::mem::PinMut; use futures_core::{Future, Stream, Poll, task}; use {StableFuture, StableStream}; @@ -17,7 +17,7 @@ impl<'a, T: StableFuture> Future for UnsafePin { type Item = T::Item; type Error = T::Error; fn poll(&mut self, ctx: &mut task::Context) -> Poll { - T::poll(unsafe { Pin::new_unchecked(&mut self.inner) }, ctx) + T::poll(unsafe { PinMut::new_unchecked(&mut self.inner) }, ctx) } } @@ -25,6 +25,6 @@ impl<'a, T: StableStream> Stream for UnsafePin { type Item = T::Item; type Error = T::Error; fn poll_next(&mut self, ctx: &mut task::Context) -> Poll, Self::Error> { - T::poll_next(unsafe { Pin::new_unchecked(&mut self.inner) }, ctx) + T::poll_next(unsafe { PinMut::new_unchecked(&mut self.inner) }, ctx) } }