Closed
Description
Code
fn main() {
let Some(x);
x = 1;
}
Current output
error[E0005]: refutable pattern in local binding
--> src/main.rs:2:9
|
2 | let Some(x);
| ^^^^^^^ pattern `None` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: the matched value is of type `Option<i32>`
help: you might want to use `let else` to handle the variant that isn't matched
|
2 | let Some(x); else { todo!() }
| ++++++++++++++++
Desired output
error[E0005]: refutable pattern in local binding
--> src/main.rs:2:9
|
2 | let Some(x);
| ^^^^^^^ pattern `None` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: the matched value is of type `Option<i32>`
Rationale and extra context
Just drop the help suggestion, as let-else can't be used with deferred initialization let
.
Other cases
No response
Rust Version
1.79.0-nightly
(2024-04-11 a07f3eb43acc5df851e1)
Anything else?
@rustbot label +D-invalid-suggestion