Skip to content

Resolve associated items on the type Clippy already knows - #129

Open
charliermarsh wants to merge 1 commit into
charlie/honor-private-interior-mutabilityfrom
charlie/resolve-associated-items-on-reexported-types
Open

charliermarsh wants to merge 1 commit into
charlie/honor-private-interior-mutabilityfrom
charlie/resolve-associated-items-on-reexported-types

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Suppose a library defines Key in a private module and re-exports it. A client can write this without triggering clippy::manual_is_multiple_of.

Key::VALUE % 4 == 0

To suggest Key::VALUE.is_multiple_of(4), Clippy first checks that it can infer the type of VALUE. We already know which type Key refers 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-fixes applied all 120 replacements upstream made, up from 84. Compiler jobs stayed the same across 384 checks.

Closes #128.

@charliermarsh
charliermarsh force-pushed the charlie/resolve-associated-items-on-reexported-types branch from 651050d to 68af952 Compare November 26, 2026 14:32
@charliermarsh
charliermarsh marked this pull request as ready for review November 26, 2026 14:33
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.

1 participant