Skip to content

Commit 6810513

Browse files
authored
Merge pull request #1003 from sdroege/pin-mut
Update for latest nightly changes to rename Pin to PinMut
2 parents 2c15c6a + c3eacaf commit 6810513

File tree

9 files changed

+29
-29
lines changed

9 files changed

+29
-29
lines changed

futures-async-runtime/src/future.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::marker::Unpin;
2-
use std::mem::Pin;
2+
use std::mem::PinMut;
33
use std::ops::{Generator, GeneratorState};
44

55
use super::{IsResult, Reset, CTX};
@@ -25,12 +25,12 @@ impl<T> StableFuture for GenStableFuture<T>
2525
type Item = <T::Return as IsResult>::Ok;
2626
type Error = <T::Return as IsResult>::Err;
2727

28-
fn poll(mut self: Pin<Self>, ctx: &mut task::Context) -> Poll<Self::Item, Self::Error> {
28+
fn poll(self: PinMut<Self>, ctx: &mut task::Context) -> Poll<Self::Item, Self::Error> {
2929
CTX.with(|cell| {
3030
let _r = Reset::new(ctx, cell);
31-
let this: &mut Self = unsafe { Pin::get_mut(&mut self) };
31+
let this: &mut Self = unsafe { PinMut::get_mut(self) };
3232
// This is an immovable generator, but since we're only accessing
33-
// it via a Pin this is safe.
33+
// it via a PinMut this is safe.
3434
match unsafe { this.0.resume() } {
3535
GeneratorState::Yielded(Async::Pending)
3636
=> Ok(Async::Pending),

futures-async-runtime/src/stream.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::mem::Pin;
1+
use std::mem::PinMut;
22
use std::ops::{Generator, GeneratorState};
33
use std::marker::{PhantomData, Unpin};
44

@@ -37,13 +37,13 @@ impl<U, T> StableStream for GenStableStream<U, T>
3737
type Item = U;
3838
type Error = <T::Return as IsResult>::Err;
3939

40-
fn poll_next(mut self: Pin<Self>, ctx: &mut task::Context) -> Poll<Option<Self::Item>, Self::Error> {
40+
fn poll_next(self: PinMut<Self>, ctx: &mut task::Context) -> Poll<Option<Self::Item>, Self::Error> {
4141
CTX.with(|cell| {
4242
let _r = Reset::new(ctx, cell);
43-
let this: &mut Self = unsafe { Pin::get_mut(&mut self) };
43+
let this: &mut Self = unsafe { PinMut::get_mut(self) };
4444
if this.done { return Ok(Async::Ready(None)) }
4545
// This is an immovable generator, but since we're only accessing
46-
// it via a Pin this is safe.
46+
// it via a PinMut this is safe.
4747
match unsafe { this.gen.resume() } {
4848
GeneratorState::Yielded(Async::Ready(e)) => {
4949
Ok(Async::Ready(Some(e)))

futures-channel/src/mpsc/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//!
44
//! Similarly to the `std`, channel creation provides [`Receiver`](Receiver) and
55
//! [`Sender`](Sender) handles. [`Receiver`](Receiver) implements
6-
//! [`Stream`](futures_core::Stream) and allows a task to read values out of the
6+
//! [`Stream`] and allows a task to read values out of the
77
//! channel. If there is no message to read from the channel, the current task
88
//! will be awoken when a new value is sent. [`Sender`](Sender) implements the
99
//! `Sink` trait and allows a task to send messages into
@@ -333,7 +333,7 @@ impl SenderWaker {
333333
/// `buffer` "first come, first serve" slots available to all senders.
334334
///
335335
/// The [`Receiver`](Receiver) returned implements the
336-
/// [`Stream`](futures_core::Stream) trait, while [`Sender`](Sender) implements
336+
/// [`Stream`] trait, while [`Sender`](Sender) implements
337337
/// `Sink`.
338338
pub fn channel<T>(buffer: usize) -> (Sender<T>, Receiver<T>) {
339339
// Check that the requested buffer size does not exceed the maximum buffer

futures-core/src/future/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ if_std! {
147147
type Error = F::Error;
148148

149149
fn poll(&mut self, cx: &mut task::Context) -> Poll<Self::Item, Self::Error> {
150-
unsafe { ::core::mem::Pin::get_mut(&mut self.as_pin()).poll(cx) }
150+
unsafe { ::core::mem::PinMut::get_mut(self.as_pin_mut()).poll(cx) }
151151
}
152152
}
153153

futures-core/src/stream/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if_std! {
8989
type Error = S::Error;
9090

9191
fn poll_next(&mut self, cx: &mut task::Context) -> Poll<Option<Self::Item>, Self::Error> {
92-
unsafe { ::core::mem::Pin::get_mut(&mut self.as_pin()).poll_next(cx) }
92+
unsafe { ::core::mem::PinMut::get_mut(self.as_pin_mut()).poll_next(cx) }
9393
}
9494
}
9595

futures-macro-async/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ if_nightly! {
433433
let #pat = {
434434
let r = {
435435
let pin = unsafe {
436-
::futures::__rt::std::mem::Pin::new_unchecked(&mut __stream)
436+
::futures::__rt::std::mem::PinMut::new_unchecked(&mut __stream)
437437
};
438438
::futures::__rt::in_ctx(|ctx| ::futures::__rt::StableStream::poll_next(pin, ctx))
439439
};

futures-macro-await/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ macro_rules! await {
3939
let future = &mut future;
4040
// The above borrow is necessary to force a borrow across a
4141
// yield point, proving that we're currently in an immovable
42-
// generator, making the below `Pin::new_unchecked` call
42+
// generator, making the below `PinMut::new_unchecked` call
4343
// safe.
4444
loop {
4545
let poll = ::futures::__rt::in_ctx(|ctx| {
4646
let pin = unsafe {
47-
::futures::__rt::std::mem::Pin::new_unchecked(future)
47+
::futures::__rt::std::mem::PinMut::new_unchecked(future)
4848
};
4949
::futures::__rt::StableFuture::poll(pin, ctx)
5050
});

futures-stable/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if_nightly! {
2020
extern crate futures_core;
2121
extern crate futures_executor;
2222

23-
use core::mem::Pin;
23+
use core::mem::PinMut;
2424
use futures_core::{Future, Stream, Poll, task};
2525

2626
if_std! {
@@ -37,7 +37,7 @@ if_nightly! {
3737

3838
/// A trait for `Future`s which can be pinned to a particular location in memory.
3939
///
40-
/// These futures take `self` by `Pin<Self>`, rather than `&mut Self`.
40+
/// These futures take `self` by `PinMut<Self>`, rather than `&mut Self`.
4141
/// This allows types which are not [`Unpin`](::std::marker::Unpin) to guarantee
4242
/// that they won't be moved after being polled. Since they won't be moved, it's
4343
/// possible for them to safely contain references to themselves.
@@ -56,10 +56,10 @@ if_nightly! {
5656
/// Attempt to resolve the future to a final value, registering the current task
5757
/// for wakeup if the value is not yet available.
5858
///
59-
/// This method takes `self` by `Pin`, and so calling it requires putting `Self`
59+
/// This method takes `self` by `PinMut`, and so calling it requires putting `Self`
6060
/// in a [`PinBox`](::std::boxed::PinBox) using the `pin` method, or otherwise
6161
/// guaranteeing that the location of `self` will not change after a call to `poll`.
62-
fn poll(self: Pin<Self>, ctx: &mut task::Context) -> Poll<Self::Item, Self::Error>;
62+
fn poll(self: PinMut<Self>, ctx: &mut task::Context) -> Poll<Self::Item, Self::Error>;
6363

6464
/// Pin the future to a particular location by placing it on the heap.
6565
#[cfg(feature = "std")]
@@ -85,14 +85,14 @@ if_nightly! {
8585
type Item = F::Item;
8686
type Error = F::Error;
8787

88-
fn poll(mut self: Pin<Self>, ctx: &mut task::Context) -> Poll<Self::Item, Self::Error> {
89-
F::poll(unsafe { Pin::get_mut(&mut self) }, ctx)
88+
fn poll(self: PinMut<Self>, ctx: &mut task::Context) -> Poll<Self::Item, Self::Error> {
89+
F::poll(unsafe { PinMut::get_mut(self) }, ctx)
9090
}
9191
}
9292

9393
/// A trait for `Stream`s which can be pinned to a particular location in memory.
9494
///
95-
/// These streams take `self` by `Pin<Self>`, rather than `&mut Self`.
95+
/// These streams take `self` by `PinMut<Self>`, rather than `&mut Self`.
9696
/// This allows types which are not [`Unpin`](::std::marker::Unpin) to guarantee
9797
/// that they won't be moved after being polled. Since they won't be moved, it's
9898
/// possible for them to safely contain references to themselves.
@@ -110,10 +110,10 @@ if_nightly! {
110110
/// Attempt to resolve the stream to the next value, registering the current task
111111
/// for wakeup if the value is not yet available.
112112
///
113-
/// This method takes `self` by `Pin`, and so calling it requires putting `Self`
113+
/// This method takes `self` by `PinMut`, and so calling it requires putting `Self`
114114
/// in a [`PinBox`](::std::boxed::PinBox) using the `pin` method, or otherwise
115115
/// guaranteeing that the location of `self` will not change after a call to `poll`.
116-
fn poll_next(self: Pin<Self>, ctx: &mut task::Context) -> Poll<Option<Self::Item>, Self::Error>;
116+
fn poll_next(self: PinMut<Self>, ctx: &mut task::Context) -> Poll<Option<Self::Item>, Self::Error>;
117117

118118
/// Pin the stream to a particular location by placing it on the heap.
119119
#[cfg(feature = "std")]
@@ -139,8 +139,8 @@ if_nightly! {
139139
type Item = S::Item;
140140
type Error = S::Error;
141141

142-
fn poll_next(mut self: Pin<Self>, ctx: &mut task::Context) -> Poll<Option<Self::Item>, Self::Error> {
143-
S::poll_next(unsafe { Pin::get_mut(&mut self) }, ctx)
142+
fn poll_next(self: PinMut<Self>, ctx: &mut task::Context) -> Poll<Option<Self::Item>, Self::Error> {
143+
S::poll_next(unsafe { PinMut::get_mut(self) }, ctx)
144144
}
145145
}
146146
}

futures-stable/src/unsafe_pin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use core::mem::Pin;
1+
use core::mem::PinMut;
22
use futures_core::{Future, Stream, Poll, task};
33

44
use {StableFuture, StableStream};
@@ -17,14 +17,14 @@ impl<'a, T: StableFuture> Future for UnsafePin<T> {
1717
type Item = T::Item;
1818
type Error = T::Error;
1919
fn poll(&mut self, ctx: &mut task::Context) -> Poll<Self::Item, Self::Error> {
20-
T::poll(unsafe { Pin::new_unchecked(&mut self.inner) }, ctx)
20+
T::poll(unsafe { PinMut::new_unchecked(&mut self.inner) }, ctx)
2121
}
2222
}
2323

2424
impl<'a, T: StableStream> Stream for UnsafePin<T> {
2525
type Item = T::Item;
2626
type Error = T::Error;
2727
fn poll_next(&mut self, ctx: &mut task::Context) -> Poll<Option<Self::Item>, Self::Error> {
28-
T::poll_next(unsafe { Pin::new_unchecked(&mut self.inner) }, ctx)
28+
T::poll_next(unsafe { PinMut::new_unchecked(&mut self.inner) }, ctx)
2929
}
3030
}

0 commit comments

Comments
 (0)