Skip to content
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

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

Merged
merged 2 commits into from
Sep 12, 2022

Conversation

lowr
Copy link
Contributor

@lowr lowr commented Aug 30, 2022

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
Copy link
Contributor Author

lowr commented Aug 30, 2022

(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
Copy link
Member

Veykril commented Sep 12, 2022

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
Copy link
Contributor

bors commented Sep 12, 2022

📌 Commit 484d5b6 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Sep 12, 2022

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

@bors
Copy link
Contributor

bors commented Sep 12, 2022

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

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