Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,13 +1275,13 @@ fn report_non_exhaustive_match<'p, 'tcx>(
if ty.is_ptr_sized_integral() {
if ty.inner() == cx.tcx.types.usize {
err.note(format!(
"`{ty}` does not have a fixed maximum value, so half-open ranges are \
necessary to match exhaustively",
"`{ty}::MAX` is not treated as exhaustive, \
so half-open ranges are necessary to match exhaustively",
));
} else if ty.inner() == cx.tcx.types.isize {
err.note(format!(
"`{ty}` does not have fixed minimum and maximum values, so half-open \
ranges are necessary to match exhaustively",
"`{ty}::MIN` and `{ty}::MAX` are not treated as exhaustive, \
so half-open ranges are necessary to match exhaustively",
));
}
} else if ty.inner() == cx.tcx.types.str_ {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ fn main() {
//~^ ERROR non-exhaustive patterns: `usize::MAX..` not covered
//~| NOTE pattern `usize::MAX..` not covered
//~| NOTE the matched value is of type `usize`
//~| NOTE `usize` does not have a fixed maximum value
//~| NOTE `usize::MAX` is not treated as exhaustive, so half-open ranges are necessary to match exhaustively
0..=usize::MAX => {}
}

match 0isize {
//~^ ERROR non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
//~| NOTE patterns `..isize::MIN` and `isize::MAX..` not covered
//~| NOTE the matched value is of type `isize`
//~| NOTE `isize` does not have fixed minimum and maximum values
//~| NOTE `isize::MIN` and `isize::MAX` are not treated as exhaustive, so half-open ranges are necessary to match exhaustively
isize::MIN..=isize::MAX => {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | match 0usize {
| ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= note: `usize::MAX` is not treated as exhaustive, so half-open ranges are 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
|
LL ~ 0..=usize::MAX => {},
Expand All @@ -19,7 +19,7 @@ LL | match 0isize {
| ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= note: `isize::MIN` and `isize::MAX` are not treated as exhaustive, so half-open ranges are necessary to match exhaustively
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL ~ isize::MIN..=isize::MAX => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | match 0usize {
| ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= note: `usize::MAX` is not treated as exhaustive, so half-open ranges are 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
|
LL ~ 0..=usize::MAX => {},
Expand All @@ -19,7 +19,7 @@ LL | match 0isize {
| ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= note: `isize::MIN` and `isize::MAX` are not treated as exhaustive, so half-open ranges are necessary to match exhaustively
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL ~ isize::MIN..=isize::MAX => {},
Expand All @@ -33,7 +33,7 @@ LL | m!(0usize, 0..=usize::MAX);
| ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= note: `usize::MAX` is not treated as exhaustive, so half-open ranges are 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
|
LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() }
Expand All @@ -46,7 +46,7 @@ LL | m!(0usize, 0..5 | 5..=usize::MAX);
| ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= note: `usize::MAX` is not treated as exhaustive, so half-open ranges are 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
|
LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() }
Expand All @@ -59,7 +59,7 @@ LL | m!(0usize, 0..usize::MAX | usize::MAX);
| ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= note: `usize::MAX` is not treated as exhaustive, so half-open ranges are 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
|
LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() }
Expand All @@ -72,7 +72,7 @@ LL | m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::
| ^^^^^^^^^^^^^^ pattern `(usize::MAX.., _)` not covered
|
= note: the matched value is of type `(usize, bool)`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= note: `usize::MAX` is not treated as exhaustive, so half-open ranges are 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
|
LL | match $s { $($t)+ => {}, (usize::MAX.., _) => todo!() }
Expand All @@ -85,7 +85,7 @@ LL | m!(0isize, isize::MIN..=isize::MAX);
| ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= note: `isize::MIN` and `isize::MAX` are not treated as exhaustive, so half-open ranges are necessary to match exhaustively
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() }
Expand All @@ -98,7 +98,7 @@ LL | m!(0isize, isize::MIN..5 | 5..=isize::MAX);
| ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= note: `isize::MIN` and `isize::MAX` are not treated as exhaustive, so half-open ranges are necessary to match exhaustively
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() }
Expand All @@ -111,7 +111,7 @@ LL | m!(0isize, isize::MIN..=-1 | 0 | 1..=isize::MAX);
| ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= note: `isize::MIN` and `isize::MAX` are not treated as exhaustive, so half-open ranges are necessary to match exhaustively
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() }
Expand All @@ -124,7 +124,7 @@ LL | m!(0isize, isize::MIN..isize::MAX | isize::MAX);
| ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= note: `isize::MIN` and `isize::MAX` are not treated as exhaustive, so half-open ranges are necessary to match exhaustively
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() }
Expand All @@ -137,7 +137,7 @@ LL | (0isize, true),
| ^^^^^^^^^^^^^^ patterns `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered
|
= note: the matched value is of type `(isize, bool)`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= note: `isize::MIN` and `isize::MAX` are not treated as exhaustive, so half-open ranges are necessary to match exhaustively
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL | match $s { $($t)+ => {}, (..isize::MIN, _) | (isize::MAX.., _) => todo!() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ fn main() {
//~^ ERROR non-exhaustive patterns: `usize::MAX..` not covered
//~| NOTE pattern `usize::MAX..` not covered
//~| NOTE the matched value is of type `usize`
//~| NOTE `usize` does not have a fixed maximum value
//~| NOTE `usize::MAX` is not treated as exhaustive, so half-open ranges are necessary to match exhaustively
0..=usize::MAX => {}
}

match 0isize {
//~^ ERROR non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
//~| NOTE patterns `..isize::MIN` and `isize::MAX..` not covered
//~| NOTE the matched value is of type `isize`
//~| NOTE `isize` does not have fixed minimum and maximum values
//~| NOTE `isize::MIN` and `isize::MAX` are not treated as exhaustive, so half-open ranges are necessary to match exhaustively
isize::MIN..=isize::MAX => {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | match 0usize {
| ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= note: `usize::MAX` is not treated as exhaustive, so half-open ranges are 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
|
LL ~ 0..=usize::MAX => {},
Expand All @@ -19,7 +19,7 @@ LL | match 0isize {
| ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= note: `isize::MIN` and `isize::MAX` are not treated as exhaustive, so half-open ranges are necessary to match exhaustively
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL ~ isize::MIN..=isize::MAX => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | match 0 {
| ^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= note: `usize::MAX` is not treated as exhaustive, so half-open ranges are 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
|
LL ~ 1..=usize::MAX => (),
Expand All @@ -19,7 +19,7 @@ LL | match (0usize, 0usize) {
| ^^^^^^^^^^^^^^^^ pattern `(usize::MAX.., _)` not covered
|
= note: the matched value is of type `(usize, usize)`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= note: `usize::MAX` is not treated as exhaustive, so half-open ranges are 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
|
LL ~ (1..=usize::MAX, 1..=usize::MAX) => (),
Expand All @@ -33,7 +33,7 @@ LL | match (0isize, 0usize) {
| ^^^^^^^^^^^^^^^^ patterns `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered
|
= note: the matched value is of type `(isize, usize)`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= note: `isize::MIN` and `isize::MAX` are not treated as exhaustive, so half-open ranges are necessary to match exhaustively
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL ~ (isize::MIN..=isize::MAX, 1..=usize::MAX) => (),
Expand Down Expand Up @@ -70,7 +70,7 @@ note: `Option<usize>` defined here
|
= note: not covered
= note: the matched value is of type `Option<usize>`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= note: `usize::MAX` is not treated as exhaustive, so half-open ranges are 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
|
LL ~ None => (),
Expand All @@ -93,7 +93,7 @@ note: `Option<Option<Option<usize>>>` defined here
|
= note: not covered
= note: the matched value is of type `Option<Option<Option<usize>>>`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= note: `usize::MAX` is not treated as exhaustive, so half-open ranges are 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
|
LL ~ None => (),
Expand All @@ -112,7 +112,7 @@ note: `A<usize>` defined here
LL | struct A<T> {
| ^
= note: the matched value is of type `A<usize>`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= note: `usize::MAX` is not treated as exhaustive, so half-open ranges are 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
|
LL ~ A { a: 1..=usize::MAX } => (),
Expand All @@ -131,7 +131,7 @@ note: `B<isize, usize>` defined here
LL | struct B<T, U>(T, U);
| ^
= note: the matched value is of type `B<isize, usize>`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= note: `isize::MIN` and `isize::MAX` are not treated as exhaustive, so half-open ranges are necessary to match exhaustively
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL ~ B(isize::MIN..=isize::MAX, 1..=usize::MAX) => (),
Expand All @@ -150,7 +150,7 @@ note: `B<isize, usize>` defined here
LL | struct B<T, U>(T, U);
| ^
= note: the matched value is of type `B<isize, usize>`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= note: `usize::MAX` is not treated as exhaustive, so half-open ranges are 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
|
LL ~ B(_, 1..=usize::MAX) => (),
Expand Down
Loading