Skip to content

Replace match with if let produced bogus results #19443

Open
@WhyNotHugo

Description

@WhyNotHugo

rust-analyzer version: rust-analyzer-2025.02.24-r0
rustc version: rustc 1.85.0 (4d91de4e4 2025-02-17) (Alpine Linux 1.85.0-r1)
editor or extension: neovim-0.10.4-r1
relevant settings: n/a

code snippet to reproduce:

    match failed.load(Ordering::Relaxed) {
        0 => {
            info!("Repair complete, no failures.");
            Ok(())
        }
        some => bail!("A total of {some} operations failed."),
    }

For the above snippet, the Replace match with if let action produces:

    if let some = failed.load(Ordering::Relaxed) {
        bail!("A total of {some} operations failed.")
    } else {
        info!("Repair complete, no failures.");
        Ok(())
    }

The latter is not equivalent to the former: the else branch never matches for it.

Related to (but distinct from): #11373

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions