Skip to content

Commit

Permalink
Fix nightly breakage
Browse files Browse the repository at this point in the history
Generators now use `Pin` to make `resume` safe: rust-lang/rust#55704
  • Loading branch information
phil-opp committed Feb 1, 2019
1 parent c0dfeda commit 1546558
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ pub mod future {
impl<T: Generator<Yield = ()>> Future for GenFuture<T> {
type Output = T::Return;
fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Self::Output> {
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),
})
}
}
Expand Down

0 comments on commit 1546558

Please sign in to comment.