fix: handle trait methods as inherent methods for trait-related types#13147
Merged
bors merged 2 commits intorust-lang:masterfrom Sep 12, 2022
Merged
fix: handle trait methods as inherent methods for trait-related types#13147bors merged 2 commits intorust-lang:masterfrom
bors merged 2 commits intorust-lang:masterfrom
Conversation
Contributor
Author
|
Never mind, I managed to solve the same issue for placeholder types. We should also handle trait methods as inherent if the placeholder type for which we're resolving method is bounded by traits. Although I believe this is the correct fix, please double check; I'm writing the patch as I'm familiarizing myself with how rustc does method resolution. |
Member
|
Judging from the rust source this looks correct to me, if it breaks anything we can revert it since we just pushed a stable release |
Contributor
Contributor
Contributor
|
☀️ Test successful - checks-actions |
bors
added a commit
that referenced
this pull request
Sep 19, 2022
…hods, r=lnicola Revert "fix: handle trait methods as inherent methods for trait-related types" Reverts #13147 https://github.com/rust-lang/rust-analyzer/actions/runs/3041499441/jobs/4898678721#step:18:62
lnicola
added a commit
that referenced
this pull request
Sep 19, 2022
bors
added a commit
that referenced
this pull request
Sep 19, 2022
…hods, r=lnicola fix: Fix a crash introduced in #13147 Reverts #13147 https://github.com/rust-lang/rust-analyzer/actions/runs/3041499441/jobs/4898678721#step:18:62
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.
Fixes #10677
When resolving methods for trait object types and placeholder types that are bounded by traits, we need to count the methods of the trait and its super traits as inherent methods. This matters because these trait methods have higher priority than the other traits' methods.
Relevant code in rustc:
assemble_inherent_candidates_from_object()for trait object types,assemble_inherent_candidates_from_param()for placeholder types. Notice the second arg ofpush_candidate()isis_inherent.