diff options
| author | David Tolnay <dtolnay@gmail.com> | 2021-04-28 08:47:09 -0700 |
|---|---|---|
| committer | David Tolnay <dtolnay@gmail.com> | 2021-07-30 10:42:18 -0700 |
| commit | 6d988dc1e307db8e04442a75a757f6aeb7b3c2c9 (patch) | |
| tree | b624b9799602f316290aac6dc3545dc8fb172d5f | |
| parent | 4e17994b2ca5da45f219ad09cad591fc7d31dd59 (diff) | |
| download | rust-6d988dc1e307db8e04442a75a757f6aeb7b3c2c9.tar.gz rust-6d988dc1e307db8e04442a75a757f6aeb7b3c2c9.zip | |
Fix undocumented unsafe in AssertUnwindSafe impls
| -rw-r--r-- | library/core/src/panic/unwind_safe.rs | 2 |
1 files changed, 2 insertions, 0 deletions
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<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) } @@ -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) } |
