Skip to content

Weird clippy suggestion #15589

@Snoupix

Description

@Snoupix

Summary

It might just be me but this clippy lint feels wrong.

Lint Name

clippy::collapsible_if

Reproducer

POC

let x: Result<(), ()> = Err(());
if 1 > 2 {
    if let Err(_err) = x {}
}

// Clippy suggests

match 1 > 2 {
    true => if let Err(_err) = x {}
    false => (),
}

Now that if-let-chains are stabilized, it should suggest something like this:

if 1 > 2 && let Err(_err) = x {}

IMO For older rust versions, it souldn't suggest anything if one of the if statements is a if let.

Version

rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: x86_64-unknown-linux-gnu
release: 1.89.0
LLVM version: 20.1.7

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions