Closed
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