From 6d988dc1e307db8e04442a75a757f6aeb7b3c2c9 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 28 Apr 2021 08:47:09 -0700 Subject: [PATCH] Fix undocumented unsafe in AssertUnwindSafe impls --- library/core/src/panic/unwind_safe.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/core/src/panic/unwind_safe.rs b/library/core/src/panic/unwind_safe.rs index c889dd81846..a1ee47e4d48 100644 --- a/library/core/src/panic/unwind_safe.rs +++ b/library/core/src/panic/unwind_safe.rs @@ -281,6 +281,7 @@ impl Future for AssertUnwindSafe { type Output = F::Output; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + // 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) } @@ -291,6 +292,7 @@ impl Stream for AssertUnwindSafe { type Item = S::Item; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + // SAFETY: pin projection. AssertUnwindSafe follows structural pinning. unsafe { self.map_unchecked_mut(|x| &mut x.0) }.poll_next(cx) }