Skip to content

fix: handle trait methods as inherent methods for trait-related types#13147

Merged
bors merged 2 commits into
rust-lang:masterfrom
lowr:fix/dyn-ty-inherent-methods
Sep 12, 2022
Merged

fix: handle trait methods as inherent methods for trait-related types#13147
bors merged 2 commits into
rust-lang:masterfrom
lowr:fix/dyn-ty-inherent-methods

Conversation

@lowr

@lowr lowr commented Aug 30, 2022

Copy link
Copy Markdown
Contributor

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 of push_candidate() is is_inherent.

@lowr lowr marked this pull request as draft August 30, 2022 11:55
@lowr lowr marked this pull request as ready for review August 30, 2022 13:30
@lowr

lowr commented Aug 30, 2022

Copy link
Copy Markdown
Contributor Author

(I was trying to resolve another somewhat related issue but gave up; this PR can be reviewed regardless)

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.

@lowr lowr changed the title fix: handle trait methods as inherent methods for trait object types fix: handle trait methods as inherent methods for trait-related types Aug 30, 2022
@Veykril

Veykril commented Sep 12, 2022

Copy link
Copy Markdown
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
@bors r+

@bors

bors commented Sep 12, 2022

Copy link
Copy Markdown
Contributor

📌 Commit 484d5b6 has been approved by Veykril

It is now in the queue for this repository.

@bors

bors commented Sep 12, 2022

Copy link
Copy Markdown
Contributor

⌛ Testing commit 484d5b6 with merge 7a704f2...

@bors

bors commented Sep 12, 2022

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 7a704f2 to master...

@bors bors merged commit 7a704f2 into rust-lang:master Sep 12, 2022
bors added a commit that referenced this pull request Sep 19, 2022
lnicola added a commit that referenced this pull request Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

try_into from custom trait misresolved for prelude TryInto in 2021 edition

3 participants