Update to a new pinning API.

This commit is contained in:
Without Boats 2018-09-01 06:12:10 +02:00
parent e6b35b0e11
commit 974bdc80fe
No known key found for this signature in database
GPG key ID: 174625E5E877C0D9
14 changed files with 340 additions and 451 deletions

View file

@ -12,7 +12,7 @@
use core::cell::Cell;
use core::marker::Unpin;
use core::pin::PinMut;
use core::pin::Pin;
use core::option::Option;
use core::ptr::NonNull;
use core::task::{self, Poll};
@ -42,8 +42,8 @@ impl<T: Generator<Yield = ()>> !Unpin for GenFuture<T> {}
#[unstable(feature = "gen_future", issue = "50547")]
impl<T: Generator<Yield = ()>> Future for GenFuture<T> {
type Output = T::Return;
fn poll(self: PinMut<Self>, cx: &mut task::Context) -> Poll<Self::Output> {
set_task_cx(cx, || match unsafe { PinMut::get_mut_unchecked(self).0.resume() } {
fn poll(self: Pin<&mut Self>, cx: &mut task::Context) -> Poll<Self::Output> {
set_task_cx(cx, || match unsafe { Pin::get_mut_unchecked(self).0.resume() } {
GeneratorState::Yielded(()) => Poll::Pending,
GeneratorState::Complete(x) => Poll::Ready(x),
})
@ -108,9 +108,9 @@ where
#[unstable(feature = "gen_future", issue = "50547")]
/// Polls a future in the current thread-local task context.
pub fn poll_in_task_cx<F>(f: PinMut<F>) -> Poll<F::Output>
pub fn poll_in_task_cx<F>(f: Pin<&mut F>) -> Poll<F::Output>
where
F: Future
{
get_task_cx(|cx| f.poll(cx))
get_task_cx(|cx| F::poll(f, cx))
}

View file

@ -436,7 +436,7 @@ pub use alloc_crate::fmt;
#[stable(feature = "rust1", since = "1.0.0")]
pub use alloc_crate::format;
#[unstable(feature = "pin", issue = "49150")]
pub use alloc_crate::pin;
pub use core::pin;
#[stable(feature = "rust1", since = "1.0.0")]
pub use alloc_crate::slice;
#[stable(feature = "rust1", since = "1.0.0")]

View file

@ -230,7 +230,7 @@ macro_rules! await {
loop {
if let $crate::task::Poll::Ready(x) =
$crate::future::poll_in_task_cx(unsafe {
$crate::pin::PinMut::new_unchecked(&mut pinned)
$crate::pin::Pin::new_unchecked(&mut pinned)
})
{
break x;

View file

@ -16,7 +16,7 @@ use any::Any;
use cell::UnsafeCell;
use fmt;
use future::Future;
use pin::PinMut;
use pin::Pin;
use ops::{Deref, DerefMut};
use panicking;
use ptr::{Unique, NonNull};
@ -327,9 +327,9 @@ impl<T: fmt::Debug> fmt::Debug for AssertUnwindSafe<T> {
impl<'a, F: Future> Future for AssertUnwindSafe<F> {
type Output = F::Output;
fn poll(self: PinMut<Self>, cx: &mut task::Context) -> Poll<Self::Output> {
let pinned_field = unsafe { PinMut::map_unchecked(self, |x| &mut x.0) };
pinned_field.poll(cx)
fn poll(self: Pin<&mut Self>, cx: &mut task::Context) -> Poll<Self::Output> {
let pinned_field = unsafe { Pin::map_unchecked_mut(self, |x| &mut x.0) };
F::poll(pinned_field, cx)
}
}