Repository navigation
Resolve associated items on the type Clippy already knows - #129
Open
charliermarsh wants to merge 1 commit into
Open
charliermarsh wants to merge 1 commit into
charliermarsh wants to merge 1 commit into
Conversation
charliermarsh
force-pushed
the
charlie/resolve-associated-items-on-reexported-types
branch
from
November 26, 2026 14:32
651050d to
68af952
Compare
charliermarsh
marked this pull request as ready for review
November 26, 2026 14:33
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.
Summary
Suppose a library defines
Keyin a private module and re-exports it. A client can write this without triggeringclippy::manual_is_multiple_of.To suggest
Key::VALUE.is_multiple_of(4), Clippy first checks that it can infer the type ofVALUE. We already know which typeKeyrefers to, but look it up again through the private module. Ohm can omit that path from public metadata.We now look up the associated item on the resolved type. If multiple impls define the same name, we leave the expression alone. We also keep a fallback like
Key::empty().unwrap_or(Vec::<u8>::new())when it supplies a type or const argument needed to infer the result. A trait bound can occasionally make that fallback unnecessary.Across 20 runs,
cargo fixit --clippy --Zdangerous-parallel-fixesapplied all 120 replacements upstream made, up from 84. Compiler jobs stayed the same across 384 checks.Closes #128.