-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
Summary
apparently we detect boolan expressions of the form x == y
but we don't detect fn(&self) -> bool
ones???
I get it that this can be iffy if sideeffects are involved but in this example the fn does not even need &mut self
:/
Could we somehow warn here for const-fns at least maybe?
Lint Name
ifs_same_cond
Reproducer
I tried this code:
pub fn main() {
let a = Some(32);
if let Some(32) = a {
let b = String::from("x");
if b.contains("ah") { // same as
eprintln!("AAA");
} else if b.contains("ah") { // here
println!("AAA");
}
}
}
I expected to see this happen:
clippy warning
Instead, this happened:
Version
rustc 1.69.0-nightly (dc1d9d50f 2023-01-31)
binary: rustc
commit-hash: dc1d9d50fba2f6a1ccab8748a0050cde38253f60
commit-date: 2023-01-31
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't