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

[len_without_is_empty]: follow type alias to find inherent is_empty method #11452

Merged
merged 1 commit into from Sep 14, 2023

Conversation

y21
Copy link
Member

@y21 y21 commented Sep 2, 2023

Fixes #11165

When we see an impl B and B is a type alias to some type A, then we need to follow the type alias to look for an is_empty method on the aliased type A. Before this PR, it'd get the inherent impls of B, which there aren't any and so it would warn that there isn't an is_empty method even if there was one.
Passing the type alias DefId to TyCtxt::type_of gives us the aliased DefId (or simply return the type itself if it wasn't a type alias) so we can just use that

changelog: [len_without_is_empty]: follow type alias to find inherent is_empty method

@rustbot
Copy link
Collaborator

rustbot commented Sep 2, 2023

r? @Centri3

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 2, 2023
@Centri3
Copy link
Member

Centri3 commented Sep 13, 2023

Bit weird how inherent_impls doesn't already do this (i.e., strip type aliases), but looks fine to me regardless. Thanks!

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 13, 2023

📌 Commit 26c0f97 has been approved by Centri3

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Sep 13, 2023

⌛ Testing commit 26c0f97 with merge 2009b58...

@bors
Copy link
Collaborator

bors commented Sep 14, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Centri3
Pushing 2009b58 to master...

@bors bors merged commit 2009b58 into rust-lang:master Sep 14, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clippy::len_without_is_empty bug when implementing on a type alias
4 participants