rust-lang / rust-lang/rust-clippy

Warn if a `[patch.*]` section is used on a dependency of a library

Open
#12,975 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.