Closed
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