Skip to content

Commit fbd2cd0

Browse files
committed
Revert a diagnostic change in the case of integer ranges
1 parent d44774d commit fbd2cd0

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

src/librustc_mir/hair/pattern/_match.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1778,8 +1778,9 @@ pub fn is_useful<'p, 'tcx>(
17781778
// satisfied with `(_, _, true)`. In this case,
17791779
// `used_ctors` is empty.
17801780
// The exception is: if we are at the top-level, for example in an empty match, we
1781-
// prefer reporting the list of constructors instead of just `_`.
1782-
if missing_ctors.all_ctors_are_missing() && !is_top_level {
1781+
// sometimes prefer reporting the list of constructors instead of just `_`.
1782+
let report_ctors_rather_than_wildcard = is_top_level && !IntRange::is_integral(pcx.ty);
1783+
if missing_ctors.all_ctors_are_missing() && !report_ctors_rather_than_wildcard {
17831784
// All constructors are unused. Add a wild pattern
17841785
// rather than each individual constructor.
17851786
usefulness.apply_wildcard(pcx.ty)

src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn main() {
7777
//~^ ERROR `V1`, `V2`, `V3` and 2 more not covered
7878

7979
match_false!(0u8);
80-
//~^ ERROR `0u8..=std::u8::MAX` not covered
80+
//~^ ERROR `_` not covered
8181
match_false!(NonEmptyStruct(true));
8282
//~^ ERROR `NonEmptyStruct(_)` not covered
8383
match_false!((NonEmptyUnion1 { foo: () }));

src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ LL | match_empty!(NonEmptyEnum5::V1);
123123
|
124124
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
125125

126-
error[E0004]: non-exhaustive patterns: `0u8..=std::u8::MAX` not covered
126+
error[E0004]: non-exhaustive patterns: `_` not covered
127127
--> $DIR/match-empty-exhaustive_patterns.rs:79:18
128128
|
129129
LL | match_false!(0u8);
130-
| ^^^ pattern `0u8..=std::u8::MAX` not covered
130+
| ^^^ pattern `_` not covered
131131
|
132132
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
133133

src/test/ui/pattern/usefulness/match-empty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn main() {
7676
//~^ ERROR `V1`, `V2`, `V3` and 2 more not covered
7777

7878
match_false!(0u8);
79-
//~^ ERROR `0u8..=std::u8::MAX` not covered
79+
//~^ ERROR `_` not covered
8080
match_false!(NonEmptyStruct(true));
8181
//~^ ERROR `NonEmptyStruct(_)` not covered
8282
match_false!((NonEmptyUnion1 { foo: () }));

src/test/ui/pattern/usefulness/match-empty.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ LL | match_empty!(NonEmptyEnum5::V1);
104104
|
105105
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
106106

107-
error[E0004]: non-exhaustive patterns: `0u8..=std::u8::MAX` not covered
107+
error[E0004]: non-exhaustive patterns: `_` not covered
108108
--> $DIR/match-empty.rs:78:18
109109
|
110110
LL | match_false!(0u8);
111-
| ^^^ pattern `0u8..=std::u8::MAX` not covered
111+
| ^^^ pattern `_` not covered
112112
|
113113
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
114114

src/test/ui/pattern/usefulness/match-non-exhaustive.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ LL | match 0 { 1 => () }
66
|
77
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
88

9-
error[E0004]: non-exhaustive patterns: `std::i32::MIN..=std::i32::MAX` not covered
9+
error[E0004]: non-exhaustive patterns: `_` not covered
1010
--> $DIR/match-non-exhaustive.rs:3:11
1111
|
1212
LL | match 0 { 0 if false => () }
13-
| ^ pattern `std::i32::MIN..=std::i32::MAX` not covered
13+
| ^ pattern `_` not covered
1414
|
1515
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
1616

0 commit comments

Comments
 (0)