Skip to content

Commit

Permalink
Rollup merge of #81363 - jonhoo:no-unpin-in-pin-future-impl, r=m-ou-se
Browse files Browse the repository at this point in the history
Remove P: Unpin bound on impl Future for Pin

We can safely produce a `Pin<&mut P::Target>` without moving out of the `Pin` by using `Pin::as_mut` directly.

The `Unpin` bound was originally added in #56939 following the recommendation of ``@withoutboats`` in rust-lang/rust#55766 (comment)

That comment does not give explicit justification for why the bound should be added. The relevant context was:

> [ ] Remove `impl<P> Unpin for Pin<P>`
>
> This impl is not justified by our standard justification for unpin impls: there is no pointer direction between `Pin<P>` and `P`. Its usefulness is covered by the impls for pointers themselves.
>
> This futures impl (link to the impl changed in this PR) will need to change to add a `P: Unpin` bound.

The decision to remove the unconditional impl of `Unpin for Pin` is sound (these days there is just an auto-impl for when `P: Unpin`). But, I think the decision to also add the `Unpin` bound for `impl Future` may have been unnecessary. Or if that's not the case, I'd be very interested to have the argument for why written down somewhere. The bound _appears_ to not be needed, as demonstrated by the change requiring no unsafe code and by the existence of `Pin::as_mut`.
  • Loading branch information
JohnTitor authored Jul 28, 2021
2 parents 392ae45 + a82e5f2 commit 2d112b0
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 2d112b0

Please sign in to comment.