From 83e40c40b1e1d168ff0515461410d8ed4ca5f1d8 Mon Sep 17 00:00:00 2001 From: Raushan kumar Date: Tue, 26 May 2026 08:36:10 +0000 Subject: [PATCH 1/2] docs(usage): document build.warnings config option --- book/src/usage.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/book/src/usage.md b/book/src/usage.md index 23edf6c2abaa..99fdb01cd538 100644 --- a/book/src/usage.md +++ b/book/src/usage.md @@ -47,6 +47,24 @@ cargo clippy -- -Dwarnings > are found in your code. That includes warnings found by rustc (e.g. > `dead_code`, etc.). +Alternatively, since Cargo 1.97, you can use the [`build.warnings`] config option: + +```toml +# .cargo/config.toml +[build] +warnings = "deny" +``` + +Or via environment variable: + +```bash +CARGO_BUILD_WARNINGS=deny cargo clippy +``` + +Unlike `-Dwarnings`, this does not invalidate build caches and only affects lint warnings. + +[`build.warnings`]: https://doc.rust-lang.org/cargo/reference/config.html#buildwarnings + For more information on configuring lint levels, see the [rustc documentation]. [rustc documentation]: https://doc.rust-lang.org/rustc/lints/levels.html#configuring-warning-levels From f4bb8c03d4356762ef04d0d812d3773a7aab7a0f Mon Sep 17 00:00:00 2001 From: Raushan kumar Date: Tue, 26 May 2026 08:36:16 +0000 Subject: [PATCH 2/2] docs(readme): document build.warnings config option --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 8bccd040c1f9..24499f021f46 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,24 @@ That includes warnings found by rustc (e.g. `dead_code`, etc.). If you want to a an error for Clippy warnings, use `#![deny(clippy::all)]` in your code or `-D clippy::all` on the command line. (You can swap `clippy::all` with the specific lint category you are targeting.) +Alternatively, since Cargo 1.97, you can use the [`build.warnings`] config option: + +```toml +# .cargo/config.toml +[build] +warnings = "deny" +``` + +Or via environment variable: + +```bash +CARGO_BUILD_WARNINGS=deny cargo clippy +``` + +Unlike `-Dwarnings`, this does not invalidate build caches and only affects lint warnings. + +[`build.warnings`]: https://doc.rust-lang.org/cargo/reference/config.html#buildwarnings + ## Configuration ### Allowing/denying lints