Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elide lifetimes in Pin<&mut Self> #1753

Merged
merged 1 commit into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ matrix:
# This is the minimum Rust version supported by `async-await` feature.
# When updating this, the reminder to update the minimum required version of `async-await` feature in README.md.
- name: cargo +nightly build (minimum required version)
rust: nightly-2019-05-09
rust: nightly-2019-07-29
script:
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml */Cargo.toml
- cargo build --all --all-features
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ prevent it from compiling. To use futures-rs with async/await, use:
futures-preview = { version = "=0.3.0-alpha.17", features = ["async-await", "nightly"] }
```

The current `async-await` feature requires Rust nightly 2019-05-09 or later.
The current `async-await` feature requires Rust nightly 2019-07-29 or later.

# License

Expand Down
16 changes: 8 additions & 8 deletions futures-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ mod if_std {
/// `Interrupted`. Implementations must convert `WouldBlock` into
/// `Poll::Pending` and either internally retry or convert
/// `Interrupted` into another error kind.
fn poll_fill_buf<'a>(self: Pin<&'a mut Self>, cx: &mut Context<'_>)
-> Poll<Result<&'a [u8]>>;
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>)
-> Poll<Result<&[u8]>>;

/// Tells this buffer that `amt` bytes have been consumed from the buffer,
/// so they should no longer be returned in calls to [`poll_read`].
Expand Down Expand Up @@ -597,8 +597,8 @@ mod if_std {

macro_rules! deref_async_buf_read {
() => {
fn poll_fill_buf<'a>(self: Pin<&'a mut Self>, cx: &mut Context<'_>)
-> Poll<Result<&'a [u8]>>
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>)
-> Poll<Result<&[u8]>>
{
Pin::new(&mut **self.get_mut()).poll_fill_buf(cx)
}
Expand All @@ -622,8 +622,8 @@ mod if_std {
P: DerefMut + Unpin,
P::Target: AsyncBufRead,
{
fn poll_fill_buf<'a>(self: Pin<&'a mut Self>, cx: &mut Context<'_>)
-> Poll<Result<&'a [u8]>>
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>)
-> Poll<Result<&[u8]>>
{
self.get_mut().as_mut().poll_fill_buf(cx)
}
Expand All @@ -635,8 +635,8 @@ mod if_std {

macro_rules! delegate_async_buf_read_to_stdio {
() => {
fn poll_fill_buf<'a>(self: Pin<&'a mut Self>, _: &mut Context<'_>)
-> Poll<Result<&'a [u8]>>
fn poll_fill_buf(self: Pin<&mut Self>, _: &mut Context<'_>)
-> Poll<Result<&[u8]>>
{
Poll::Ready(io::BufRead::fill_buf(self.get_mut()))
}
Expand Down
10 changes: 5 additions & 5 deletions futures-test/src/interleave_pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<T> InterleavePending<T> {

/// Acquires a pinned mutable reference to the underlying I/O object that
/// this adaptor is wrapping.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut T> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T> {
self.project().0
}

Expand All @@ -56,7 +56,7 @@ impl<T> InterleavePending<T> {
self.inner
}

fn project<'a>(self: Pin<&'a mut Self>) -> (Pin<&'a mut T>, &'a mut bool) {
fn project(self: Pin<&mut Self>) -> (Pin<&mut T>, &mut bool) {
unsafe {
let this = self.get_unchecked_mut();
(Pin::new_unchecked(&mut this.inner), &mut this.pended)
Expand Down Expand Up @@ -185,10 +185,10 @@ impl<R: AsyncRead> AsyncRead for InterleavePending<R> {
}

impl<R: AsyncBufRead> AsyncBufRead for InterleavePending<R> {
fn poll_fill_buf<'a>(
self: Pin<&'a mut Self>,
fn poll_fill_buf(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<io::Result<&'a [u8]>> {
) -> Poll<io::Result<&[u8]>> {
let (reader, pended) = self.project();
if *pended {
let next = reader.poll_fill_buf(cx);
Expand Down
8 changes: 4 additions & 4 deletions futures-test/src/io/limited.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<Io> Limited<Io> {

/// Acquires a pinned mutable reference to the underlying I/O object that
/// this adaptor is wrapping.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Io> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut Io> {
self.io()
}

Expand Down Expand Up @@ -89,10 +89,10 @@ impl<R: AsyncRead> AsyncRead for Limited<R> {
}

impl<R: AsyncBufRead> AsyncBufRead for Limited<R> {
fn poll_fill_buf<'a>(
self: Pin<&'a mut Self>,
fn poll_fill_buf(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<io::Result<&'a [u8]>> {
) -> Poll<io::Result<&[u8]>> {
self.io().poll_fill_buf(cx)
}

Expand Down
6 changes: 3 additions & 3 deletions futures-util/src/future/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ mod if_std {
A: AsyncBufRead,
B: AsyncBufRead,
{
fn poll_fill_buf<'a>(
self: Pin<&'a mut Self>,
fn poll_fill_buf(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<&'a [u8]>> {
) -> Poll<Result<&[u8]>> {
unsafe {
match self.get_unchecked_mut() {
Either::Left(x) => Pin::new_unchecked(x).poll_fill_buf(cx),
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/future/flatten_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum State<Fut, St> {
}

impl<Fut, St> State<Fut, St> {
fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> State<Pin<&'a mut Fut>, Pin<&'a mut St>> {
fn get_pin_mut(self: Pin<&mut Self>) -> State<Pin<&mut Fut>, Pin<&mut St>> {
// safety: data is never moved via the resulting &mut reference
match unsafe { self.get_unchecked_mut() } {
// safety: the future we're re-pinning here will never be moved;
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/future/join_all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<F> ElemState<F>
where
F: Future,
{
fn pending_pin_mut<'a>(self: Pin<&'a mut Self>) -> Option<Pin<&'a mut F>> {
fn pending_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut F>> {
// Safety: Basic enum pin projection, no drop + optionally Unpin based
// on the type of this variant
match unsafe { self.get_unchecked_mut() } {
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/future/maybe_done.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<Fut: Future> MaybeDone<Fut> {
/// future has been completed and [`take_output`](MaybeDone::take_output)
/// has not yet been called.
#[inline]
pub fn output_mut<'a>(self: Pin<&'a mut Self>) -> Option<&'a mut Fut::Output> {
pub fn output_mut(self: Pin<&mut Self>) -> Option<&mut Fut::Output> {
unsafe {
let this = self.get_unchecked_mut();
match this {
Expand Down
4 changes: 2 additions & 2 deletions futures-util/src/io/allow_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ impl<T> io::BufRead for AllowStdIo<T> where T: io::BufRead {
}

impl<T> AsyncBufRead for AllowStdIo<T> where T: io::BufRead {
fn poll_fill_buf<'a>(mut self: Pin<&'a mut Self>, _: &mut Context<'_>)
-> Poll<io::Result<&'a [u8]>>
fn poll_fill_buf(mut self: Pin<&mut Self>, _: &mut Context<'_>)
-> Poll<io::Result<&[u8]>>
{
let this: *mut Self = &mut *self as *mut _;
Poll::Ready(Ok(try_with_interrupt!(unsafe { &mut *this }.0.fill_buf())))
Expand Down
8 changes: 4 additions & 4 deletions futures-util/src/io/buf_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<R: AsyncRead> BufReader<R> {
/// Gets a pinned mutable reference to the underlying reader.
///
/// It is inadvisable to directly read from the underlying reader.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut R> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut R> {
self.inner()
}

Expand Down Expand Up @@ -172,10 +172,10 @@ impl<R: AsyncRead> AsyncRead for BufReader<R> {
}

impl<R: AsyncRead> AsyncBufRead for BufReader<R> {
fn poll_fill_buf<'a>(
self: Pin<&'a mut Self>,
fn poll_fill_buf(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<io::Result<&'a [u8]>> {
) -> Poll<io::Result<&[u8]>> {
let Self { inner, buf, cap, pos } = unsafe { self.get_unchecked_mut() };
let mut inner = unsafe { Pin::new_unchecked(inner) };

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/io/buf_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<W: AsyncWrite> BufWriter<W> {
/// Gets a pinned mutable reference to the underlying writer.
///
/// It is inadvisable to directly write to the underlying writer.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut W> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut W> {
self.inner()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/io/copy_buf_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl<R, W: ?Sized> CopyBufInto<'_, R, W> {
}

impl<R, W: Unpin + ?Sized> CopyBufInto<'_, R, W> {
fn project<'b>(self: Pin<&'b mut Self>) -> (Pin<&'b mut R>, Pin<&'b mut W>, &'b mut u64) {
fn project(self: Pin<&mut Self>) -> (Pin<&mut R>, Pin<&mut W>, &mut u64) {
unsafe {
let this = self.get_unchecked_mut();
(Pin::new_unchecked(&mut this.reader), Pin::new(&mut *this.writer), &mut this.amt)
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/io/into_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<W: AsyncWrite, Item: AsRef<[u8]>> IntoSink<W, Item> {
IntoSink { writer, buffer: None }
}

fn project<'a>(self: Pin<&'a mut Self>) -> (Pin<&'a mut W>, &'a mut Option<Block<Item>>) {
fn project(self: Pin<&mut Self>) -> (Pin<&mut W>, &mut Option<Block<Item>>) {
unsafe {
let this = self.get_unchecked_mut();
(Pin::new_unchecked(&mut this.writer), &mut this.buffer)
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/sink/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<Si: Sink<Item>, Item> Buffer<Si, Item> {
}

/// Get a pinned mutable reference to the inner sink.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Si> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut Si> {
self.sink()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/sink/err_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<Si, E, Item> SinkErrInto<Si, Item, E>
}

/// Get a pinned mutable reference to the inner sink.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Si> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut Si> {
self.sink().get_pin_mut()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/sink/fanout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<Si1, Si2> Fanout<Si1, Si2> {
}

/// Get a pinned mutable reference to the inner sinks.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> (Pin<&'a mut Si1>, Pin<&'a mut Si2>)
pub fn get_pin_mut(self: Pin<&mut Self>) -> (Pin<&mut Si1>, Pin<&mut Si2>)
where Si1: Unpin, Si2: Unpin,
{
let Self { sink1, sink2 } = self.get_mut();
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/sink/map_err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<Si, F> SinkMapErr<Si, F> {
}

/// Get a pinned mutable reference to the inner sink.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Si> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut Si> {
self.sink()
}

Expand Down
6 changes: 2 additions & 4 deletions futures-util/src/sink/with.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ enum State<Fut, T> {

impl<Fut, T> State<Fut, T> {
#[allow(clippy::wrong_self_convention)]
fn as_pin_mut<'a>(
self: Pin<&'a mut Self>,
) -> State<Pin<&'a mut Fut>, Pin<&'a mut T>> {
fn as_pin_mut(self: Pin<&mut Self>) -> State<Pin<&mut Fut>, Pin<&mut T>> {
unsafe {
match self.get_unchecked_mut() {
State::Empty =>
Expand Down Expand Up @@ -118,7 +116,7 @@ impl<Si, Item, U, Fut, F, E> With<Si, Item, U, Fut, F>
}

/// Get a pinned mutable reference to the inner sink.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Si> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut Si> {
self.sink()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/sink/with_flat_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ where
}

/// Get a pinned mutable reference to the inner sink.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Si> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut Si> {
self.sink()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/buffer_unordered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ where
///
/// Note that care must be taken to avoid tampering with the state of the
/// stream which may otherwise confuse this combinator.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.stream().get_pin_mut()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ where
///
/// Note that care must be taken to avoid tampering with the state of the
/// stream which may otherwise confuse this combinator.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.stream().get_pin_mut()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<St: Stream> Chunks<St> where St: Stream {
///
/// Note that care must be taken to avoid tampering with the state of the
/// stream which may otherwise confuse this combinator.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.stream().get_pin_mut()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/enumerate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<St: Stream> Enumerate<St> {
///
/// Note that care must be taken to avoid tampering with the state of the
/// stream which may otherwise confuse this combinator.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.stream()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ where St: Stream,
///
/// Note that care must be taken to avoid tampering with the state of the
/// stream which may otherwise confuse this combinator.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.stream()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/filter_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<St, Fut, F> FilterMap<St, Fut, F>
///
/// Note that care must be taken to avoid tampering with the state of the
/// stream which may otherwise confuse this combinator.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.stream()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ where
///
/// Note that care must be taken to avoid tampering with the state of the
/// stream which may otherwise confuse this combinator.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.stream()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/fuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<St> Fuse<St> {
///
/// Note that care must be taken to avoid tampering with the state of the
/// stream which may otherwise confuse this combinator.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.stream()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/futures_unordered/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl<Fut> FuturesUnordered<Fut> {
}

/// Returns an iterator that allows modifying each future in the set.
pub fn iter_pin_mut<'a>(self: Pin<&'a mut Self>) -> IterPinMut<'a, Fut> {
pub fn iter_pin_mut(self: Pin<&mut Self>) -> IterPinMut<'_, Fut> {
IterPinMut {
task: self.head_all,
len: self.len(),
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<St, F> Inspect<St, F>
///
/// Note that care must be taken to avoid tampering with the state of the
/// stream which may otherwise confuse this combinator.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.stream()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/into_future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<St: Stream + Unpin> StreamFuture<St> {
/// implementation of `Future::poll` consumes the underlying stream during polling
/// in order to return it to the caller of `Future::poll` if the stream yielded
/// an element.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Option<Pin<&'a mut St>> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut St>> {
Pin::new(&mut self.get_mut().stream).as_pin_mut()
}

Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<St, T, F> Map<St, F>
///
/// Note that care must be taken to avoid tampering with the state of the
/// stream which may otherwise confuse this combinator.
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut St> {
self.stream()
}

Expand Down
Loading