rust-lang / rust-lang/rust-clippy

`manual_let_else` doesn't trigger if binding has a type annotation.

Open
#10,150 3 comments 0 reactions 1 assignee View on GitHub

@ericwu17 is already working on this.

Since Jan 6, 2023.

C-bug I-false-negative
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Summary

manual_let_else doesn't trigger if binding has a type annotation.

Lint Name

manual_let_else

Reproducer

I tried this code:

#![warn(clippy::pedantic)]
#![allow(unused_variables)]

fn main() {
    let x: u32 = match "14".parse() {
        Ok(i) => i,
        Err(_) => return,
    };
}

I expected to see this happen:
A suggestion to use:

let Ok(i): Result<u32, _> = "14".parse() else { return };

Instead, this happened:
Nothing. This is a false negative.

Version
clippy: 0.1.68 (2023-01-02 d6f99e5)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.