Skip to content

Commit 1546558

Browse files
committed
Fix nightly breakage
Generators now use `Pin` to make `resume` safe: rust-lang/rust#55704
1 parent c0dfeda commit 1546558

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

core/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ pub mod future {
3737
impl<T: Generator<Yield = ()>> Future for GenFuture<T> {
3838
type Output = T::Return;
3939
fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Self::Output> {
40-
set_task_waker(lw, || {
41-
match unsafe { Pin::get_unchecked_mut(self).0.resume() } {
42-
GeneratorState::Yielded(()) => Poll::Pending,
43-
GeneratorState::Complete(x) => Poll::Ready(x),
44-
}
40+
// Safe because we're !Unpin + !Drop mapping to a ?Unpin value
41+
let gen = unsafe { Pin::map_unchecked_mut(self, |s| &mut s.0) };
42+
set_task_waker(lw, || match gen.resume() {
43+
GeneratorState::Yielded(()) => Poll::Pending,
44+
GeneratorState::Complete(x) => Poll::Ready(x),
4545
})
4646
}
4747
}

0 commit comments

Comments
 (0)