Cargo clippy "-D warnings" failures in CI
CI runs clippy with -D warnings, which promotes every lint to an error. A clippy suggestion that is a harmless warning locally fails the pipeline, so the build stops on lints your local cargo build ignores.
What this error means
The clippy step fails with one or more error: ... lines (each ending in #[deny(clippy::...)] on by default) plus error: aborting due to N previous errors. It is deterministic for the source and clippy version.
error: this `.clone()` on a Copy type is redundant
--> src/calc.rs:8:13
|
8 | let y = x.clone();
| ^^^^^^^^^ help: try removing the `.clone()`: `x`
|
= note: `-D clippy::clone-on-copy` implied by `-D warnings`Common causes
Warnings promoted to errors
The CI invocation passes -- -D warnings, so any clippy lint -- even a style nit -- becomes a build-failing error.
New lints from a clippy upgrade
A newer toolchain ships new lints that fire on existing code, breaking a previously green build.
How to fix it
Fix the lints clippy reports
Apply the suggestions; many are auto-fixable.
cargo clippy --fix --allow-dirty --workspace
cargo clippy --workspace --all-targets -- -D warningsAllow a specific lint deliberately
When a lint is a false positive, allow it narrowly rather than dropping -D warnings.
#[allow(clippy::clone_on_copy)] // justified: trait-object boundary
let y = x.clone();How to prevent it
- Run
cargo clippy -- -D warningslocally before pushing. - Pin the clippy toolchain so a CI upgrade does not surprise you with new lints.
- Allow individual lints with justification instead of disabling the gate.