Change:
Consider the following code, taken from the (): Local pin construction was stabilized in . We should update the diagnostics to suggest this instead of the more expensive call. No response cc/ This is probably a "good first issue" as well. If someone can tag it as such? <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
In some cases, works but does not (e.g., if you want ownership of the pinned future), so I think it's better to suggest both. Or something like:
claim
Alright, the suggestion has been in . IDK how to link a PR to an issue though, should I just reference the issue in the description of the PR?
if you put " in the PR description, it will automatically close this issue when the PR is merged :)

Discussion:
/// [`pin` module]: crate::pin #[stable(feature = "pin", since = "1.33.0")] #[rustc_on_unimplemented( <del> note = "consider using `Box::pin`", </del> <ins> note = "consider using the `pin!` macronconsider using `Box::pin` if you need to access the pinned value outside of the current scope", </ins> message = "`{Self}` cannot be unpinned" )] #[lang = "unpin"]

|         | |         required by a bound introduced by this call | <del> = note: consider using `Box::pin` </del> <ins> = note: consider using the `pin!` macro consider using `Box::pin` if you need to access the pinned value outside of the current scope </ins> note: required because it appears within the type `Sleep` --> $DIR/pin-needed-to-poll-2.rs:8:8 |

|     | |     required by a bound introduced by this call | <del> = note: consider using `Box::pin` </del> <ins> = note: consider using the `pin!` macro consider using `Box::pin` if you need to access the pinned value outside of the current scope </ins> note: required by a bound in `assert_unpin` --> $DIR/static-not-unpin.rs:7:20 |

|     | |     required by a bound introduced by this call | <del> = note: consider using `Box::pin` </del> <ins> = note: consider using the `pin!` macro consider using `Box::pin` if you need to access the pinned value outside of the current scope </ins> note: required by a bound in `Pin::<P>::new` --> $SRC_DIR/core/src/pin.rs:LL:COL

|     | |     required by a bound introduced by this call | <del> = note: consider using `Box::pin` </del> <ins> = note: consider using the `pin!` macro consider using `Box::pin` if you need to access the pinned value outside of the current scope </ins> note: required by a bound in `f_unpin` --> $DIR/issue-84973-blacklist.rs:8:15 |

<ins> use std::pin::Pin; use std::marker::PhantomPinned; #[derive(Debug)] struct Test { _marker: PhantomPinned, } impl Test { fn new() -> Self { Test { _marker: PhantomPinned, // This makes our type `!Unpin` } } } fn dummy(_: &mut Test) {} pub fn main() { let mut test1 = Test::new(); let mut test1 = unsafe { Pin::new_unchecked(&mut test1) }; dummy(test1.get_mut()); //~ ERROR E0277 } </ins>

<ins> error[E0277]: `PhantomPinned` cannot be unpinned --> $DIR/suggest-pin-macro.rs:22:17 | LL |     dummy(test1.get_mut()); |                 ^^^^^^^ within `Test`, the trait `Unpin` is not implemented for `PhantomPinned` | = note: consider using the `pin!` macro consider using `Box::pin` if you need to access the pinned value outside of the current scope note: required because it appears within the type `Test` --> $DIR/suggest-pin-macro.rs:5:8 | LL | struct Test { |        ^^^^ note: required by a bound in `Pin::<&'a mut T>::get_mut` --> $SRC_DIR/core/src/pin.rs:LL:COL error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. </ins>

|     | |     required by a bound introduced by this call | <del> = note: consider using `Box::pin` </del> <ins> = note: consider using the `pin!` macro consider using `Box::pin` if you need to access the pinned value outside of the current scope </ins> note: required by a bound in `copy` --> $DIR/issue-90164.rs:1:12 |