Skip to content

Commit ee8e646

Browse files
authored
Rollup merge of rust-lang#110259 - ndrewxie:issue-109964-fix-gitstuff, r=cjgillot
Added diagnostic for pin! macro in addition to Box::pin if Unpin isn't implemented I made a PR earlier, but accidentally renamed a branch and that deleted the PR... sorry for the duplicate Currently, if an operation on `Pin<T>` is performed that requires `T` to implement `Unpin`, the diagnostic suggestion is to use `Box::pin` ("note: consider using `Box::pin`"). This PR suggests pin! as well, as that's another valid way of pinning a value, and avoids a heap allocation. Appropriate diagnostic suggestions were included to highlight the difference in semantics (local pinning for pin! vs non-local for Box::pin). Fixes rust-lang#109964
2 parents 933b21a + 15f68a6 commit ee8e646

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/src/marker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
823823
/// [`pin` module]: crate::pin
824824
#[stable(feature = "pin", since = "1.33.0")]
825825
#[rustc_on_unimplemented(
826-
note = "consider using `Box::pin`",
826+
note = "consider using the `pin!` macro\nconsider using `Box::pin` if you need to access the pinned value outside of the current scope",
827827
message = "`{Self}` cannot be unpinned"
828828
)]
829829
#[lang = "unpin"]

0 commit comments

Comments
 (0)