Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if_then_panic doesn't fire when edition is 2021 #7723

Closed
ghost opened this issue Sep 26, 2021 · 0 comments · Fixed by #7851
Closed

if_then_panic doesn't fire when edition is 2021 #7723

ghost opened this issue Sep 26, 2021 · 0 comments · Fixed by #7851
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@ghost
Copy link

ghost commented Sep 26, 2021

Lint name: if_then_panic

I tried this code:

src/main.rs

#![warn(clippy::if_then_panic)]

fn main() {
    if true { panic!("ABC"); };
}

Cargo.toml

[package]
name = "play_if_else_panic_1"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

I expected to see this happen: The lint to be triggered

Instead, this happened: Nothing. It's a false negative.

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

Comments

I think the problem is that rustc produces different HIR for panic! in the 2021 edition and clippy_utils::higher doesn't handle it. It's possible that other lints will have similar problems.

@ghost ghost added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Sep 26, 2021
@bors bors closed this as completed in 276e895 Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
0 participants