diff options
| author | Adrian Taylor <adetaylor@chromium.org> | 2024-12-02 15:02:59 +0000 |
|---|---|---|
| committer | Adrian Taylor <adetaylor@chromium.org> | 2024-12-14 20:27:15 +0000 |
| commit | b27817c8c605499dc8269c5d1ad34527be8c52f2 (patch) | |
| tree | 19548ab5b79aa7757c15e42f2502bf9d028b661f /compiler/rustc_hir_analysis/messages.ftl | |
| parent | 85641f729f43b3b826f2269f82817ea0b577613f (diff) | |
| download | rust-b27817c8c605499dc8269c5d1ad34527be8c52f2.tar.gz rust-b27817c8c605499dc8269c5d1ad34527be8c52f2.zip | |
Arbitrary self types v2: Weak, NonNull hints
Various types can be used as method receivers, such as Rc<>, Box<> and Arc<>. The arbitrary self types v2 work allows further types to be made method receivers by implementing the Receiver trait. With that in mind, it may come as a surprise to people when certain common types do not implement Receiver and thus cannot be used as a method receiver. The RFC for arbitrary self types v2 therefore proposes emitting specific lint hints for these cases: * NonNull * Weak * Raw pointers The code already emits a hint for this third case, in that it advises folks that the `arbitrary_self_types_pointers` feature may meet their need. This PR adds diagnostic hints for the Weak and NonNull cases.
Diffstat (limited to 'compiler/rustc_hir_analysis/messages.ftl')
| -rw-r--r-- | compiler/rustc_hir_analysis/messages.ftl | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_hir_analysis/messages.ftl b/compiler/rustc_hir_analysis/messages.ftl index a2df0ba265c..0c3ed9b5c60 100644 --- a/compiler/rustc_hir_analysis/messages.ftl +++ b/compiler/rustc_hir_analysis/messages.ftl @@ -249,6 +249,12 @@ hir_analysis_invalid_receiver_ty_help = hir_analysis_invalid_receiver_ty_help_no_arbitrary_self_types = consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`) +hir_analysis_invalid_receiver_ty_help_nonnull_note = + `NonNull` does not implement `Receiver` because it has methods that may shadow the referent; consider wrapping your `NonNull` in a newtype wrapper for which you implement `Receiver` + +hir_analysis_invalid_receiver_ty_help_weak_note = + `Weak` does not implement `Receiver` because it has methods that may shadow the referent; consider wrapping your `Weak` in a newtype wrapper for which you implement `Receiver` + hir_analysis_invalid_receiver_ty_no_arbitrary_self_types = invalid `self` parameter type: `{$receiver_ty}` .note = type of `self` must be `Self` or a type that dereferences to it |
