about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-04-13 21:58:37 +0200
committerGitHub <noreply@github.com>2023-04-13 21:58:37 +0200
commite413c2e77072bbf2803dca63bea239c461159831 (patch)
treef93d4e6b322601f8b9cb0246e3f0ae4b401639b8 /library/core/src
parente85ecbbcdcc577d47baae3c0c537c82056340ac9 (diff)
parent9e0e4c31aa88e5d510fdd0742808ec95329470e4 (diff)
downloadrust-e413c2e77072bbf2803dca63bea239c461159831.tar.gz
rust-e413c2e77072bbf2803dca63bea239c461159831.zip
Rollup merge of #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 #109964
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/marker.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs
index 62064f1aa6c..3cd4f5104ce 100644
--- a/library/core/src/marker.rs
+++ b/library/core/src/marker.rs
@@ -823,7 +823,7 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
 /// [`pin` module]: crate::pin
 #[stable(feature = "pin", since = "1.33.0")]
 #[rustc_on_unimplemented(
-    note = "consider using `Box::pin`",
+    note = "consider using the `pin!` macro\nconsider using `Box::pin` if you need to access the pinned value outside of the current scope",
     message = "`{Self}` cannot be unpinned"
 )]
 #[lang = "unpin"]