Skip to content
Latchkey

Rust Clippy "-D warnings" / pedantic Lints Failing CI

CI runs cargo clippy with lints promoted to errors - -D warnings, #![deny(clippy::pedantic)], or -D clippy::all - so any triggered lint fails the build. The code compiles; the lint gate is what rejects it.

What this error means

A cargo clippy step fails with error: ... for a lint (often a clippy::pedantic or style lint), where without -D it would only be a warning. It frequently appears after a toolchain bump adds new lints, or after enabling pedantic.

clippy output
error: this argument is passed by value, but not consumed in the function body
  --> src/lib.rs:5:18
   |
5  | fn parse(input: String) -> usize { input.len() }
   |                  ^^^^^^ help: consider taking a reference: `&str`
   = note: `-D clippy::needless-pass-by-value` implied by `-D clippy::pedantic`

Common causes

Lints promoted to hard errors

With -D warnings or deny(clippy::pedantic), every triggered lint is an error. Pedantic in particular is opinionated and flags a lot of otherwise-acceptable code.

A new toolchain introduced new lints

A newer Rust/clippy adds lints or tightens existing ones. Code that passed before now trips a freshly-added lint that the deny turns into a failure.

How to fix it

Fix the lint clippy suggests

Clippy’s help: line usually gives the exact change. Apply it - that’s the intended outcome of the gate.

Rust
// take a reference instead of consuming the String
fn parse(input: &str) -> usize { input.len() }

Scope an allow for a deliberate exception

When a pedantic lint is wrong for a specific case, allow it narrowly with a reason - not a crate-wide blanket allow.

Rust
#[allow(clippy::needless_pass_by_value)] // API requires owned value for the trait impl
fn handler(req: Request) { /* ... */ }

How to prevent it

  • Run cargo clippy -- -D warnings locally so lints surface before CI.
  • Adopt clippy::pedantic incrementally, allowing noisy lints with reasons.
  • Pin the clippy/toolchain version so new lints don’t fail CI unexpectedly.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →