Skip to content

manual_let_else not suggesting a fix for match statement #14598

@nyurik

Description

@nyurik

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

Metadata

Metadata

Assignees

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