Closed
Description
followup to #7383 and pinging @xFrednet
Lint name: if_same_then_else
I tried this code:
#[allow(unused_variables)]
fn main() {
let a = true;
let b = Some(true);
if let Some(b) = b {
println!("hello");
}
else if a {
println!("hello");
}
}
I expected to see this happen:
no lint warning, since I cannot express this until if-let-chains are supported
Instead, this happened:
Checking playground v0.0.1 (/playground)
error: this `if` has identical blocks
--> src/main.rs:6:24
|
6 | if let Some(b) = b {
| ________________________^
7 | | println!("hello");
8 | | }
| |_____^
|
= note: `#[deny(clippy::if_same_then_else)]` on by default
note: same as this
--> src/main.rs:9:15
|
9 | else if a {
| _______________^
10 | | println!("hello");
11 | | }
| |_____^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
error: could not compile `playground` due to previous error
Meta
cargo clippy -V
: clippy 0.1.56 (0035d9d 2021-08-16)rustc -Vv
:
rustc 1.54.0 (a178d0322 2021-07-26)
binary: rustc
commit-hash: a178d0322ce20e33eac124758e837cbd80a6f633
commit-date: 2021-07-26
host: x86_64-apple-darwin
release: 1.54.0
LLVM version: 12.0.1