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

Replace match with if let produced bogus results #19443

Open
WhyNotHugo opened this issue Mar 24, 2025 · 0 comments
Open

Replace match with if let produced bogus results #19443

WhyNotHugo opened this issue Mar 24, 2025 · 0 comments
Labels
A-assists C-bug Category: bug

Comments

@WhyNotHugo
Copy link

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

@WhyNotHugo WhyNotHugo added the C-bug Category: bug label Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants