- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.F-if_let_guard`#![feature(if_let_guard)]``#![feature(if_let_guard)]`F-let_chains`#![feature(let_chains)]``#![feature(let_chains)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
#![feature(if_let_guard, let_chains)]
fn main() {
    let opt = Some(1);
    match 1 {
        1 | 2
            if let Some(x) = opt
                && true =>
        {
            x;
        }
        _ => {}
    }
}I expected to see this happen: the code compiles.
Instead, this happened: it doesn't compile.
error[E0381]: used binding `x` is possibly-uninitialized
  --> y.rs:10:13
   |
7  |             if let Some(x) = opt
   |                         -
   |                         |
   |                         binding initialized here in some conditions
   |                         binding declared here but left uninitialized
...
10 |             x;
   |             ^ `x` used here but it is possibly-uninitialized
If I remove the && true, it does compile.
Meta
rustc --version --verbose:
rustc 1.76.0-nightly (87e1447aa 2023-11-30)
binary: rustc
commit-hash: 87e1447aadaa2899ff6ccabe1fa669eb50fb60a1
commit-date: 2023-11-30
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.F-if_let_guard`#![feature(if_let_guard)]``#![feature(if_let_guard)]`F-let_chains`#![feature(let_chains)]``#![feature(let_chains)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.