Closed

Description
I tried this code:
#![warn(clippy::if_then_panic)]
fn main() {
if false && false {
// comment
panic!("ABC");
};
}
I expected to see this happen: The suggestion would be equivalent but use assert
instead.
Instead, this happened:
--> src/main.rs:5:5
|
5 | / if false && false {
6 | | // comment
7 | | panic!("ABC");
8 | | };
| |_____^ help: try: `assert!(!false && false, "ABC");`
The suggestion doesn't correctly negate the condition and so changes the logic of the code. My original code will never panic. The suggestion will always panic.
Meta
Rust version (rustc -Vv
):
rustc 1.57.0-nightly (fdf65053e 2021-09-07)
binary: rustc
commit-hash: fdf65053e99e8966f9bd83b5a8491326cb33d638
commit-date: 2021-09-07
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0
@rustbot label +L-suggestion