You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Yes, but does a new contributor know that? Typically you would use a if statement here, if we see this then most likely a user has mistyped let _6 = 5; or something to that effect. A non-pattern binding here would be more common.
I tried this code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=d53daa961c3b462df261d1e774a9329f
I expected to see an error explaining the limits on identifiers (identifiers can't start with digits).
Instead, I got a pattern-matching error:
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
The text was updated successfully, but these errors were encountered: