rust/tests/ui/missing/missing-let.rs
Usman Akinyemi 85ca098f55 rustc_parse: improve the error diagnostic for "missing let"
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
2026-02-07 22:12:04 +05:30

18 lines
641 B
Rust

fn main() {
let x = Some(42);
let y = Some(42);
let z = Some(42);
if let Some(_) = x
&& Some(x) = x //~^ ERROR expected expression, found `let` statement
//~| NOTE: only supported directly in conditions of `if` and `while` expressions
{}
if Some(_) = y &&
//~^ NOTE expected `let` expression, found assignment
//~| ERROR let-chain with missing `let`
let Some(_) = z
//~^ ERROR: expected expression, found `let` statement
//~| NOTE: let expression later in the condition
//~| NOTE: only supported directly in conditions of `if` and `while` expressions
{}
}