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
When trying to pattern match an usize, no ranges seem to be able to satisfy it, even if the ranges would automatically cover the entire added/removed range if usize's size changes. There seems to be a hard requirement of _.
error[E0004]: non-exhaustive patterns: `_` not covered
--> src/main.rs:2:11
|
2 | match4usize{
| ^^^^^^ pattern `_` not covered
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
3 ~ 0.. => println!("anything else"),4 ~ _ => todo!(),
|
For more information about this error, try `rustc --explain E0004`.
However, switching to u64 makes it work again:
- match 4usize {+ match 4u64 {
Sidenote: Changing 0.. to 0..=usize::MAX yields the same error.
Workaround
Adding _ as a new branch on the last match branch. Clippy cries about it though.
The text was updated successfully, but these errors were encountered:
Noratrieb
changed the title
Ranges cannot satisfy the whole usize domain, but can do so on u64
Range patterns cannot satisfy the whole usize domain
Jun 26, 2023
When trying to pattern match an
usize
, no ranges seem to be able to satisfy it, even if the ranges would automatically cover the entire added/removed range ifusize
's size changes. There seems to be a hard requirement of_
.MVCE
fails with
However, switching to
u64
makes it work again:Sidenote: Changing
0..
to0..=usize::MAX
yields the same error.Workaround
Adding
_
as a new branch on the last match branch. Clippy cries about it though.Environment
The text was updated successfully, but these errors were encountered: