Closed as duplicate of#11782
Description
Problem
The [patch]
section in .cargo/config.toml
is very useful to override certain dependencies (even if it's no uploaded to crates.io) of multiple projects.
But the downside is, for projects that do not use those patched dependencies, cargo will repeatedly show warnings about those being unused, which seems annoying over time.
Example
In .cargo/config.toml
[patch.crates-io]
foo = { path = "/path/to/foo" }
bar = { path = "/path/to/bar" }
after running
cargo init hello_world
cargo run
warning: Patch `foo v0.1.0 (/path/to/foo)` was not used in the crate graph.
Patch `bar v0.1.0 (/path/to/bar)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
Proposed Solution
possible solutions (might not be the best)
- Add a configuration key under
[patch]
:[patch.crates-io] ... allow-unused = true
- Skip unused patch warning entirely if the
[patch]
configuration is coming fromconfig.toml
Notes
No response