-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlC-bugCategory: This is a bug.Category: This is a bug.F-if_let_guard`#![feature(if_let_guard)]``#![feature(if_let_guard)]`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.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Description
I tried this code:
#![feature(if_let_guard)]
fn main() {
match () {
() | () if let x = 0 => {
x;
},
_ => {}
};
}
I expected to see this happen: code compiles successfully
Instead, this happened: the compiler complains about x
being possibly uninitialized
error[E0381]: use of possibly-uninitialized variable: `x`
--> src/main.rs:5:34
|
5 | () | () if let x = () => x,
| ^ use of possibly-uninitialized `x`
This is because each candidate subpattern introduces a different local for x
.
cc tracking issue #51114.
Meta
rustc --version --verbose
:
rustc 1.56.0-nightly (ccffcafd5 2021-08-11)
binary: rustc
commit-hash: ccffcafd55e58f769d4b0efc0064bf65e76998e4
commit-date: 2021-08-11
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1
osa1, Frago9876543210, AlexTMjugador, slanterns and FilipAndersson245
Metadata
Metadata
Assignees
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlC-bugCategory: This is a bug.Category: This is a bug.F-if_let_guard`#![feature(if_let_guard)]``#![feature(if_let_guard)]`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.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.