Skip to content

let-else: linting for unused bindings is not handled correctly #89807

Closed
@nagisa

Description

@nagisa
#![feature(let_else)]

fn example_let_else(value: Option<String>) {
    #[allow(unused)]
    let banana = 1;
    #[allow(unused)]
    let Some(chaenomeles) = value else { return };
}

here banana will not be linted against as an unused variable, but chaenomeleswill be:

warning: unused variable: `chaenomeles`
 --> src/lib.rs:7:14
  |
7 |     let Some(chaenomeles) = value else { return };
  |              ^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_chaenomeles`
  |
  = note: `#[warn(unused_variables)]` on by default

playground

cc #87335

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.B-unstableBlocker: Implemented in the nightly compiler and unstable.F-let_elseIssues related to let-else statements (RFC 3137)requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions