Skip to content

manual_let_else not suggesting a fix for match statement #14598

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

Closed
nyurik opened this issue Apr 12, 2025 · 1 comment · Fixed by #14732
Closed

manual_let_else not suggesting a fix for match statement #14598

nyurik opened this issue Apr 12, 2025 · 1 comment · Fixed by #14732
Assignees
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

@nyurik
Copy link
Contributor

nyurik commented Apr 12, 2025

Summary

An expected suggistion was not made

Lint Name

manual_let_else

Reproducer

I tried this code:

fn main(){
    assert!(bar().is_ok());
}

fn bar() -> Result<bool, &'static str> {
    let value = match foo() {
        Err(_) => return Err("abc"),
        Ok(value) => value,
    };

    Ok(value == 42)
}

#[allow(clippy::unnecessary_wraps)]
fn foo() -> Result<u32, &'static str>  {
    Ok(42)
}

I expected this suggestion for the let value = ... statement:

    let Ok(value) = foo() else {
        return Err("abc");
    };

Instead, there were no suggestions.

Version

rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: x86_64-unknown-linux-gnu
release: 1.86.0
LLVM version: 19.1.7
@nyurik nyurik 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 Apr 12, 2025
@profetia
Copy link
Contributor

@rustbot claim

github-merge-queue bot pushed a commit that referenced this issue May 7, 2025
Closes #14598

Implemented checks for simple enum variants when checking if match arms
are disjointed.

changelog: [`manual_let_else`] fix FN when diverges on simple enum
variant
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
Development

Successfully merging a pull request may close this issue.

2 participants