Skip to content

Commit

Permalink
Auto merge of rust-lang#102737 - RalfJung:poll_fn_pin, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
poll_fn and Unpin: fix pinning

See [IRLO](https://internals.rust-lang.org/t/surprising-soundness-trouble-around-pollfn/17484) for details: currently `poll_fn` is very subtle to use, since it does not pin the closure, so creating a `Pin::get_unchcked(&mut capture)` inside the closure is unsound. This leads to actual miscompilations with `futures::join!`.

IMO the proper fix is to pin the closure when the future is pinned, which is achieved by changing the `Unpin` implementation. This is a breaking change though. 1.64.0 was *just* released, so maybe this is still okay?

The alternative would be to add some strong comments to the docs saying that closure captures are *not pinned* and doing `Pin::get_unchecked` on them is unsound.
  • Loading branch information
bors committed Oct 28, 2022
2 parents 0f0a237 + 7ee48ea commit 7a8ef6e
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 7a8ef6e

Please sign in to comment.