-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
base: master
Are you sure you want to change the base?
Conversation
The recently landed PR to adjust arbitrary self types was a bit overenthusiastic, advising folks to use the new Receiver trait even before it's been stabilized. Revert to the older wording of the lint in such cases.
@@ -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.
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.
4fc0de2
to
5e6fa12
Compare
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