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.
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
- Locate the
#[expect(...)]named in the message. - Remove it if the code no longer needs to suppress that lint.
- Re-run clippy to confirm the expectation lint is gone.
cargo clippy -- -D warningsSwitch to allow if you truly want suppression
If you want to suppress the lint regardless of whether it fires, use #[allow(...)] instead of #[expect(...)].
#[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.