-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.F-lint_reasons`#![feature(lint_reasons)]``#![feature(lint_reasons)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Minimal reproducer:
#[expect(clippy::derived_hash_with_manual_eq)]
#[derive(Hash)]
pub struct Thing;
impl PartialEq<Thing> for Thing {
fn eq(&self, _other: &Thing) -> bool {
true
}
}
I ran cargo clippy
, and I expected the expect
to suppress the clippy::derived_hash_with_manual_eq
lint. Instead, I got the following:
error: you are deriving `Hash` but have implemented `PartialEq` explicitly
--> src/lib.rs:2:10
|
2 | #[derive(Hash)]
| ^^^^
|
note: `PartialEq` implemented here
--> src/lib.rs:5:1
|
5 | impl PartialEq<Thing> for Thing {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derived_hash_with_manual_eq
= note: `#[deny(clippy::derived_hash_with_manual_eq)]` on by default
= note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: this lint expectation is unfulfilled
--> src/lib.rs:1:10
|
1 | #[expect(clippy::derived_hash_with_manual_eq)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unfulfilled_lint_expectations)]` on by default
I haven't found any way to apply the expect
to the derive except by putting it on the containing module.
Note, however, that replacing the expect
with an allow
does successfully suppress the warning. This seems particularly surprising, and violates the expectation that replacing an allow
with an expect
should always work.
Meta
rustc --version --verbose
:
rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.F-lint_reasons`#![feature(lint_reasons)]``#![feature(lint_reasons)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.