Skip to content

fix: replace 'Pin<_>' with '&mut Pin<_>' for Pin::set #1410

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

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 5 additions & 3 deletions futures-util/src/future/fuse.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use core::pin::Pin;
use futures_core::future::{Future, FusedFuture};
use futures_core::task::{LocalWaker, Poll};

use pin_utils::unsafe_pinned;

use futures_core::future::{FusedFuture, Future};
use futures_core::task::{LocalWaker, Poll};

/// A future which "fuses" a future once it has been resolved.
/// This wrapper can be used to turn any `Future` into a `FusedFuture`.
///
Expand Down Expand Up @@ -50,7 +52,7 @@ impl<Fut: Future> Future for Fuse<Fut> {
None => return Poll::Pending,
};

Pin::set(self.as_mut().future(), None);
Pin::set(&mut self.as_mut().future(), None);
Poll::Ready(v)
}
}
2 changes: 1 addition & 1 deletion futures-util/src/future/into_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<Fut: Future> Stream for IntoStream<Fut> {
None => return Poll::Ready(None),
};

Pin::set(self.as_mut().future(), None);
Pin::set(&mut self.as_mut().future(), None);
Poll::Ready(Some(v))
}
}
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 @@ -107,7 +107,7 @@ impl<Fut: Future> Future for MaybeDone<Fut> {
MaybeDone::Gone => panic!("MaybeDone polled after value taken"),
}
};
Pin::set(self, MaybeDone::Done(res));
Pin::set(&mut self, MaybeDone::Done(res));
Poll::Ready(())
}
}
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 @@ -102,7 +102,7 @@ where
};
}
}
Pin::set(stream, None);
Pin::set(&mut stream, None);
Poll::Ready(Ok(()))
}
}
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/stream/unfold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<T, F, Fut, It> Stream for Unfold<T, F, Fut>
) -> Poll<Option<It>> {
if let Some(state) = self.as_mut().state().take() {
let fut = (self.as_mut().f())(state);
Pin::set(self.as_mut().fut(), Some(fut));
Pin::set(&mut self.as_mut().fut(), Some(fut));
}

let step = ready!(self.as_mut().fut().as_pin_mut().unwrap().poll(lw));
Expand Down
4 changes: 2 additions & 2 deletions futures-util/src/try_future/flatten_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ where
Waiting(f) => try_ready!(f.try_poll(lw)),
Closed => panic!("poll_ready called after eof"),
};
Pin::set(self.as_mut(), FlattenSink(Ready(resolved_stream)));
Pin::set(&mut self.as_mut(), FlattenSink(Ready(resolved_stream)));
if let Ready(resolved_stream) = self.project_pin() {
resolved_stream.poll_ready(lw)
} else {
Expand Down Expand Up @@ -99,7 +99,7 @@ where
Waiting(_) | Closed => Poll::Ready(Ok(())),
};
if res.is_ready() {
Pin::set(self, FlattenSink(Closed));
Pin::set(&mut self, FlattenSink(Closed));
}
res
}
Expand Down
4 changes: 2 additions & 2 deletions futures-util/src/try_stream/try_for_each.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ impl<St, Fut, F> Future for TryForEach<St, Fut, F>
if let Some(future) = self.as_mut().future().as_pin_mut() {
try_ready!(future.try_poll(lw));
}
Pin::set(self.as_mut().future(), None);
Pin::set(&mut self.as_mut().future(), None);

match ready!(self.as_mut().stream().try_poll_next(lw)) {
Some(Ok(e)) => {
let future = (self.as_mut().f())(e);
Pin::set(self.as_mut().future(), Some(future));
Pin::set(&mut self.as_mut().future(), Some(future));
}
Some(Err(e)) => return Poll::Ready(Err(e)),
None => return Poll::Ready(Ok(())),
Expand Down