diff --git a/core/src/lib.rs b/core/src/lib.rs index 256268fc..eeb8f038 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -37,11 +37,11 @@ pub mod future { impl> Future for GenFuture { type Output = T::Return; fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll { - set_task_waker(lw, || { - match unsafe { Pin::get_unchecked_mut(self).0.resume() } { - GeneratorState::Yielded(()) => Poll::Pending, - GeneratorState::Complete(x) => Poll::Ready(x), - } + // Safe because we're !Unpin + !Drop mapping to a ?Unpin value + let gen = unsafe { Pin::map_unchecked_mut(self, |s| &mut s.0) }; + set_task_waker(lw, || match gen.resume() { + GeneratorState::Yielded(()) => Poll::Pending, + GeneratorState::Complete(x) => Poll::Ready(x), }) } }