How to suppress warnings from Cargo?

I use Cargo in concert with auto-generated Cargo.toml files, and these tend to contain a lot of redundant information. Given this, whenever I run cargo check, I get a large number of warnings before the output I care about, like:

warning: Patch `backtrace-sys v0.1.28 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/backtrace-sys)` was not used in the crate graph.
Patch `cmake v0.1.99 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/cmake)` was not used in the crate graph.
Patch `crossterm_winapi v0.6.1 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/crossterm_winapi)` was not used in the crate graph.
Patch `fatfs v0.4.0 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/fatfs)` was not used in the crate graph.
Patch `futures-timer v3.0.2 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/futures-timer)` was not used in the crate graph.
Patch `js-sys v0.3.37 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/js-sys)` was not used in the crate graph.
Patch `libm v0.2.1 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/libm)` was not used in the crate graph.
Patch `memchr v2.3.3 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/memchr)` was not used in the crate graph.
Patch `miow v0.3.5 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/miow)` was not used in the crate graph.
Patch `nom_locate v2.0.0 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/nom_locate)` was not used in the crate graph.
Patch `ntapi v0.3.4 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/ntapi)` was not used in the crate graph.
Patch `pkg-config v0.3.99 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/pkg-config)` was not used in the crate graph.
Patch `regex-automata v0.1.9 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/regex-automata)` was not used in the crate graph.
Patch `rust-crypto v0.2.36 (workspace/fuchsia/third_party/rust-mirrors/rust-crypto)` was not used in the crate graph.
Patch `security-framework v0.4.4 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/security-framework)` was not used in the crate graph.
Patch `serde_json5 v0.1.0 (workspace/fuchsia/third_party/rust-mirrors/serde_json5)` was not used in the crate graph.
Patch `servo-freetype-sys v4.0.5 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/servo-freetype-sys)` was not used in the crate graph.
Patch `termcolor v1.1.0 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/termcolor)` was not used in the crate graph.
Patch `tracing-core v0.1.10 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/tracing-core)` was not used in the crate graph.
Patch `wasm-bindgen-futures v0.4.10 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/wasm-bindgen-futures)` was not used in the crate graph.
Patch `web-sys v0.3.36 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/web-sys)` was not used in the crate graph.
Patch `wepoll-binding v2.0.2 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/wepoll-binding)` was not used in the crate graph.
Patch `winapi-i686-pc-windows-gnu v0.4.0 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/winapi-i686-pc-windows-gnu)` was not used in the crate graph.
Patch `winapi-util v0.1.5 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/winapi-util)` was not used in the crate graph.
Patch `winapi-x86_64-pc-windows-gnu v0.4.0 (workspace/fuchsia/third_party/rust_crates/tiny_mirrors/winapi-x86_64-pc-windows-gnu)` 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.

Is there any way to suppress these warnings?

As far as I know, there's no general warning-suppresion mechanism for Cargo, like there's [allow()] for Rust.

In this case you have a [patch] section with irrelevant crates, and/or outdated Cargo.lock with versions that don't match the patched crates. I don't think you can avoid these warnings other than by cleaning up these files.

OK, thanks! I'll either live with it or figure out a way to make our tooling smarter.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.