rust-lang / rust-lang/rust-clippy
Warn if a `[patch.*]` section is used on a dependency of a library
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
If a [patch] section is used to override a dependency, it is only applicable to the current crate. Dependencies ignore this. If a library tries to patch a dependency (not a dev-dependency or build-dependency) this is useless since it won't apply to anything actually using this library, but it would appear to work in tests.
Advantage
- Prevents accidental use of the
[patch]section when it won't work
Drawbacks
There might be some edge cases where this is wanted, but I'm not currently aware of any.
Example
[patch.crates-io]
foo = { git = 'https://github.com/example/foo.git' }
Would generate a clippy warning such as
The patch override for dependency `foo` will be ignored outside of this crate.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating Clippy's lint implementations and tests for Cargo manifest or dependency-related diagnostics. Reproduce the example with a library dependency and compare it with dev-dependency and build-dependency cases. Done means the requested warning is emitted only for patches that cannot affect downstream users, with tests covering the relevant dependency kinds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100