Skip to content

Commit

Permalink
Fix undocumented unsafe in AssertUnwindSafe impls
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 30, 2021
1 parent 4e17994 commit 6d988dc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions library/core/src/panic/unwind_safe.rs
Expand Up @@ -281,6 +281,7 @@ impl<F: Future> Future for AssertUnwindSafe<F> {
type Output = F::Output;

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
// SAFETY: pin projection. AssertUnwindSafe follows structural pinning.
let pinned_field = unsafe { Pin::map_unchecked_mut(self, |x| &mut x.0) };
F::poll(pinned_field, cx)
}
Expand All @@ -291,6 +292,7 @@ impl<S: Stream> Stream for AssertUnwindSafe<S> {
type Item = S::Item;

fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<S::Item>> {
// SAFETY: pin projection. AssertUnwindSafe follows structural pinning.
unsafe { self.map_unchecked_mut(|x| &mut x.0) }.poll_next(cx)
}

Expand Down

0 comments on commit 6d988dc

Please sign in to comment.