-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arbitrary self types v2: Weak & NonNull diagnostics #134264
Conversation
@@ -1749,7 +1750,20 @@ fn check_method_receiver<'tcx>( | |||
{ | |||
match receiver_validity_err { | |||
ReceiverValidityError::DoesNotDeref if arbitrary_self_types_level.is_some() => { | |||
tcx.dcx().emit_err(errors::InvalidReceiverTy { span, receiver_ty }) | |||
let hint = match receiver_ty | |||
.ty_def_id() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use this, it's an internal detail of the query system. use Ty::ty_adt_def
to check that it's an adt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - will do
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
r? compiler-errors |
maybe worth providing some background in the note to explain why
would be "ok, why don't I just suggest adding an impl to libstd?" |
This comment has been minimized.
This comment has been minimized.
4fc0de2
to
5e6fa12
Compare
Needs a rebase, then I can approve 👍 |
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.
5e6fa12
to
b27817c
Compare
@bors r+ rollup |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#132939 (Suggest using deref in patterns) - rust-lang#133293 (Updates Solaris target information, adds Solaris maintainer) - rust-lang#133392 (Fix ICE when multiple supertrait substitutions need assoc but only one is provided) - rust-lang#133986 (Add documentation for anonymous pipe module) - rust-lang#134022 (Doc: Extend for tuples to be stabilized in 1.85.0) - rust-lang#134259 (Clean up `infer_return_ty_for_fn_sig`) - rust-lang#134264 (Arbitrary self types v2: Weak & NonNull diagnostics) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#134264 - adetaylor:weak-and-nonnull, r=compiler-errors Arbitrary self types v2: Weak & NonNull diagnostics This builds on top of rust-lang#134262 which is more urgent to review and merge first. I'll likely rebase this PR once that lands. This is the first part of the diagnostic enhancements planned for Arbitrary Self Types v2. 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. Tracking issue rust-lang#44874 r? `@wesleywiser`
This builds on top of #134262 which is more urgent to review and merge first. I'll likely rebase this PR once that lands.
This is the first part of the diagnostic enhancements planned for Arbitrary Self Types v2.
Various types can be used as method receivers, such as
Rc<>
,Box<>
andArc<>
. 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
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 theWeak
andNonNull
cases.Tracking issue #44874
r? @wesleywiser