Closed
Description
I tried this code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=d53daa961c3b462df261d1e774a9329f
fn main() {
let 6 = 5;
}
I expected to see an error explaining the limits on identifiers (identifiers can't start with digits).
Instead, I got a pattern-matching error:
error[E0005]: refutable pattern in local binding: `i32::MIN..=5_i32` and `7_i32..=i32::MAX` not covered
--> src/main.rs:4:5
|
4 | let 6 = 5;
| ^ patterns `i32::MIN..=5_i32` and `7_i32..=i32::MAX` 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 `i32`
help: you might want to use `if let` to ignore the variants that aren't matched
|
4 | if let 6 = 5 { todo!() }
| ++ ~~~~~~~~~~~
While of course this error is correct, perhaps a note should be added explaining that you can't use a number as an identifier.
Meta
Occurs on latest stable and nightly.
@rustbot claim