-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't havegood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
Summary
When a type implements Not
and outputs bool
, Clippy suggests to simplify the expression !!x
to just x
, even though that isn't equivalent.
Lint Name
nonminimal_bool
Reproducer
I tried this code:
struct Foo(bool);
impl std::ops::Not for Foo {
type Output = bool;
fn not(self) -> Self::Output {
!self.0
}
}
fn main() {
let _: bool = !!Foo(true);
}
I saw this happen:
warning: this boolean expression can be simplified
--> src/report.rs:11:19
|
11 | let _: bool = !!Foo(true);
| ^^^^^^^^^^^ help: try: `Foo(true)`
|
I expected to see this happen:
This lint shouldn't have triggered.
Version
rustc 1.69.0 (84c898d65 2023-04-16)
binary: rustc
commit-hash: 84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc
commit-date: 2023-04-16
host: x86_64-apple-darwin
release: 1.69.0
LLVM version: 15.0.7
Additional Labels
No response
lochettiparviam
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't havegood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy