-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Closed
Copy link
Labels
A-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsRelating to exhaustiveness / usefulness checking of patternsA-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-bugCategory: This is a bug.Category: This is a bug.
Description
I tried this code:
fn test(a: usize) {
match a {
0.. => (),
}
}
I expected to see this happen: Successful compilation, the match is exhaustive
Instead, this happened:
error[E0004]: non-exhaustive patterns: `_` not covered
--> src/lib.rs:2:11
|
2 | match a {
| ^ 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.. => (),
4 ~ _ => todo!(),
|
For more information about this error, try `rustc --explain E0004`.
isize
(with ..=0
and 1..
patterns) has the same issue, but the other numeric types don't.
Meta
rustc --version --verbose
:
1.71.0-nightly (2023-05-21 9d871b0617a4b3d6610b)
@rustbot label A-patterns A-exhaustiveness-checking
Metadata
Metadata
Assignees
Labels
A-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsRelating to exhaustiveness / usefulness checking of patternsA-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-bugCategory: This is a bug.Category: This is a bug.