diff --git a/src/future.rs b/src/future.rs index f27df0eb..76fba131 100644 --- a/src/future.rs +++ b/src/future.rs @@ -16,7 +16,7 @@ pub(crate) struct PollFn { f: F, } -impl Unpin for PollFn {} +impl Unpin for PollFn {} pub(crate) fn poll_fn(f: F) -> PollFn where @@ -31,7 +31,8 @@ where { type Output = T; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - (self.f)(cx) + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + // SAFETY: We are not moving out of the pinned field. + (unsafe { &mut self.get_unchecked_mut().f })(cx) } }