Always mention Box::pin when dealing with !Unpin

This commit is contained in:
Esteban Küber 2021-03-30 13:51:08 -07:00
parent 8bc5581978
commit dc71166037
3 changed files with 4 additions and 1 deletions

View File

@ -765,7 +765,7 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
/// [`pin` module]: crate::pin
#[stable(feature = "pin", since = "1.33.0")]
#[rustc_on_unimplemented(
on(_Self = "std::future::Future", note = "consider using `Box::pin`",),
note = "consider using `Box::pin`",
message = "`{Self}` cannot be unpinned"
)]
#[lang = "unpin"]

View File

@ -4,6 +4,7 @@ error[E0277]: `PhantomPinned` cannot be unpinned
LL | Pin::new(&mut self.sleep).poll(cx)
| ^^^^^^^^ within `Sleep`, the trait `Unpin` is not implemented for `PhantomPinned`
|
= note: consider using `Box::pin`
note: required because it appears within the type `Sleep`
--> $DIR/pin-needed-to-poll-2.rs:8:8
|

View File

@ -6,6 +6,8 @@ LL | fn assert_unpin<T: Unpin>(_: T) {
...
LL | assert_unpin(generator);
| ^^^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:11:25: 13:6]`
|
= note: consider using `Box::pin`
error: aborting due to previous error