Arbitrary self types v2: Weak & NonNull diagnostics#134264
Merged
bors merged 1 commit intorust-lang:masterfrom Dec 15, 2024
Merged
Arbitrary self types v2: Weak & NonNull diagnostics#134264bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
18 tasks
| 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() |
Contributor
There was a problem hiding this comment.
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.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
Contributor
|
r? compiler-errors |
Contributor
|
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
Contributor
|
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
Contributor
|
@bors r+ rollup |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Dec 15, 2024
…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
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Dec 15, 2024
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`
48 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
NonNullWeakThe code already emits a hint for this third case, in that it advises folks that the
arbitrary_self_types_pointersfeature may meet their need. This PR adds diagnostic hints for theWeakandNonNullcases.Tracking issue #44874
r? @wesleywiser