Skip to content
Latchkey

clippy "this lint expectation is unfulfilled" in CI

The #[expect(lint)] attribute asserts a lint will fire there. If the code no longer triggers it, the unfulfilled_lint_expectations lint reports "this lint expectation is unfulfilled", which fails under denied warnings.

What this error means

clippy reports "warning/error: this lint expectation is unfulfilled" pointing at an #[expect(...)] attribute, even though that code looks fine.

clippy
error: this lint expectation is unfulfilled
 --> src/lib.rs:1:11
  |
1 | #![expect(clippy::needless_return)]
  |           ^^^^^^^^^^^^^^^^^^^^^^^^
  = note: `-D unfulfilled-lint-expectations` implied by `-D warnings`

Common causes

The expected lint no longer fires

Code under #[expect(lint)] was changed so the lint no longer triggers, leaving the expectation unfulfilled.

A stale expect attribute after a refactor

A refactor removed the construct the lint targeted, but the #[expect(...)] annotation was left in place.

How to fix it

Remove the stale expect attribute

  1. Locate the #[expect(...)] named in the message.
  2. Remove it if the code no longer needs to suppress that lint.
  3. Re-run clippy to confirm the expectation lint is gone.
Terminal
cargo clippy -- -D warnings

Switch to allow if you truly want suppression

If you want to suppress the lint regardless of whether it fires, use #[allow(...)] instead of #[expect(...)].

src/lib.rs
#[allow(clippy::needless_return)]

How to prevent it

  • Re-check #[expect(...)] attributes when you refactor nearby code.
  • Use #[expect] for lints you want to be told when they stop firing.
  • Use #[allow] for permanent, unconditional suppression.

Frequently asked questions

What causes ""this lint expectation is unfulfilled""?
Code under #[expect(lint)] was changed so the lint no longer triggers, leaving the expectation unfulfilled.
How do I fix "this lint expectation is unfulfilled"?
Remove the stale expect attribute

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card