Skip to content

if_then_panic doesn't fire when edition is 2021 #7723

Closed
@ghost

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions