Prefer "0..MAX not covered" to "_ not covered"
This commit is contained in:
parent
970f46c60d
commit
9dca6be7b8
7 changed files with 32 additions and 34 deletions
|
@ -1520,11 +1520,9 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
|
|||
split_ctors.push(Constructor::Missing);
|
||||
}
|
||||
|
||||
// Decide what constructors to report.
|
||||
let is_integers = matches!(ctors_for_ty, ConstructorSet::Integers { .. });
|
||||
let always_report_all = place.is_scrutinee && !is_integers;
|
||||
// Whether we should report "Enum::A and Enum::C are missing" or "_ is missing".
|
||||
let report_individual_missing_ctors = always_report_all || !all_missing;
|
||||
// Whether we should report "Enum::A and Enum::C are missing" or "_ is missing". At the top
|
||||
// level we prefer to list all constructors.
|
||||
let report_individual_missing_ctors = place.is_scrutinee || !all_missing;
|
||||
// Which constructors are considered missing. We ensure that `!missing_ctors.is_empty() =>
|
||||
// split_ctors.contains(Missing)`. The converse usually holds except when
|
||||
// `!place_validity.is_known_valid()`.
|
||||
|
|
|
@ -43,18 +43,18 @@ help: you might want to use `if let` to ignore the variant that isn't matched
|
|||
LL | if let None = x { todo!() };
|
||||
| ++ +++++++++++
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
error[E0004]: non-exhaustive patterns: `0_u8..=u8::MAX` not covered
|
||||
--> $DIR/empty-match-check-notes.rs:45:11
|
||||
|
|
||||
LL | match 0u8 {
|
||||
| ^^^ pattern `_` not covered
|
||||
| ^^^ pattern `0_u8..=u8::MAX` not covered
|
||||
|
|
||||
= note: the matched value is of type `u8`
|
||||
= note: match arms with guards don't count towards exhaustivity
|
||||
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 ~ _ if false => {},
|
||||
LL + _ => todo!()
|
||||
LL + 0_u8..=u8::MAX => todo!()
|
||||
|
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
|
|
@ -42,18 +42,18 @@ help: you might want to use `if let` to ignore the variant that isn't matched
|
|||
LL | if let None = x { todo!() };
|
||||
| ++ +++++++++++
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
error[E0004]: non-exhaustive patterns: `0_u8..=u8::MAX` not covered
|
||||
--> $DIR/empty-match-check-notes.rs:45:11
|
||||
|
|
||||
LL | match 0u8 {
|
||||
| ^^^ pattern `_` not covered
|
||||
| ^^^ pattern `0_u8..=u8::MAX` not covered
|
||||
|
|
||||
= note: the matched value is of type `u8`
|
||||
= note: match arms with guards don't count towards exhaustivity
|
||||
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 ~ _ if false => {},
|
||||
LL + _ => todo!()
|
||||
LL + 0_u8..=u8::MAX => todo!()
|
||||
|
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
|
|
@ -43,10 +43,10 @@ fn empty_foreign_enum_private(x: Option<empty::SecretlyUninhabitedForeignStruct>
|
|||
|
||||
fn main() {
|
||||
match 0u8 {
|
||||
//~^ ERROR `_` not covered
|
||||
//~^ ERROR not covered
|
||||
//~| NOTE the matched value is of type
|
||||
//~| NOTE match arms with guards don't count towards exhaustivity
|
||||
//~| NOTE pattern `_` not covered
|
||||
//~| NOTE not covered
|
||||
_ if false => {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,46 +148,46 @@ LL | V5,
|
|||
= note: the matched value is of type `NonEmptyEnum5`
|
||||
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
error[E0004]: non-exhaustive patterns: `0_u8..=u8::MAX` not covered
|
||||
--> $DIR/empty-match.rs:58:24
|
||||
|
|
||||
LL | match_guarded_arm!(0u8);
|
||||
| ^^^ pattern `_` not covered
|
||||
| ^^^ pattern `0_u8..=u8::MAX` not covered
|
||||
|
|
||||
= note: the matched value is of type `u8`
|
||||
= note: match arms with guards don't count towards exhaustivity
|
||||
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 ~ _ if false => {},
|
||||
LL + _ => todo!()
|
||||
LL + 0_u8..=u8::MAX => todo!()
|
||||
|
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
error[E0004]: non-exhaustive patterns: `i8::MIN..=i8::MAX` not covered
|
||||
--> $DIR/empty-match.rs:59:24
|
||||
|
|
||||
LL | match_guarded_arm!(0i8);
|
||||
| ^^^ pattern `_` not covered
|
||||
| ^^^ pattern `i8::MIN..=i8::MAX` not covered
|
||||
|
|
||||
= note: the matched value is of type `i8`
|
||||
= note: match arms with guards don't count towards exhaustivity
|
||||
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 ~ _ if false => {},
|
||||
LL + _ => todo!()
|
||||
LL + i8::MIN..=i8::MAX => todo!()
|
||||
|
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
error[E0004]: non-exhaustive patterns: `0_usize..` not covered
|
||||
--> $DIR/empty-match.rs:60:24
|
||||
|
|
||||
LL | match_guarded_arm!(0usize);
|
||||
| ^^^^^^ pattern `_` not covered
|
||||
| ^^^^^^ pattern `0_usize..` not covered
|
||||
|
|
||||
= note: the matched value is of type `usize`
|
||||
= note: match arms with guards don't count towards exhaustivity
|
||||
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 ~ _ if false => {},
|
||||
LL + _ => todo!()
|
||||
LL + 0_usize.. => todo!()
|
||||
|
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
|
|
|
@ -148,46 +148,46 @@ LL | V5,
|
|||
= note: the matched value is of type `NonEmptyEnum5`
|
||||
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
error[E0004]: non-exhaustive patterns: `0_u8..=u8::MAX` not covered
|
||||
--> $DIR/empty-match.rs:58:24
|
||||
|
|
||||
LL | match_guarded_arm!(0u8);
|
||||
| ^^^ pattern `_` not covered
|
||||
| ^^^ pattern `0_u8..=u8::MAX` not covered
|
||||
|
|
||||
= note: the matched value is of type `u8`
|
||||
= note: match arms with guards don't count towards exhaustivity
|
||||
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 ~ _ if false => {},
|
||||
LL + _ => todo!()
|
||||
LL + 0_u8..=u8::MAX => todo!()
|
||||
|
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
error[E0004]: non-exhaustive patterns: `i8::MIN..=i8::MAX` not covered
|
||||
--> $DIR/empty-match.rs:59:24
|
||||
|
|
||||
LL | match_guarded_arm!(0i8);
|
||||
| ^^^ pattern `_` not covered
|
||||
| ^^^ pattern `i8::MIN..=i8::MAX` not covered
|
||||
|
|
||||
= note: the matched value is of type `i8`
|
||||
= note: match arms with guards don't count towards exhaustivity
|
||||
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 ~ _ if false => {},
|
||||
LL + _ => todo!()
|
||||
LL + i8::MIN..=i8::MAX => todo!()
|
||||
|
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
error[E0004]: non-exhaustive patterns: `0_usize..` not covered
|
||||
--> $DIR/empty-match.rs:60:24
|
||||
|
|
||||
LL | match_guarded_arm!(0usize);
|
||||
| ^^^^^^ pattern `_` not covered
|
||||
| ^^^^^^ pattern `0_usize..` not covered
|
||||
|
|
||||
= note: the matched value is of type `usize`
|
||||
= note: match arms with guards don't count towards exhaustivity
|
||||
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 ~ _ if false => {},
|
||||
LL + _ => todo!()
|
||||
LL + 0_usize.. => todo!()
|
||||
|
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
|
|
|
@ -55,9 +55,9 @@ fn nonempty() {
|
|||
match_no_arms!(NonEmptyEnum2::Foo(true)); //~ ERROR `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
|
||||
match_no_arms!(NonEmptyEnum5::V1); //~ ERROR `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
|
||||
|
||||
match_guarded_arm!(0u8); //~ ERROR `_` not covered
|
||||
match_guarded_arm!(0i8); //~ ERROR `_` not covered
|
||||
match_guarded_arm!(0usize); //~ ERROR `_` not covered
|
||||
match_guarded_arm!(0u8); //~ ERROR `0_u8..=u8::MAX` not covered
|
||||
match_guarded_arm!(0i8); //~ ERROR `i8::MIN..=i8::MAX` not covered
|
||||
match_guarded_arm!(0usize); //~ ERROR `0_usize..` not covered
|
||||
match_guarded_arm!(0isize); //~ ERROR `_` not covered
|
||||
match_guarded_arm!(NonEmptyStruct1); //~ ERROR `NonEmptyStruct1` not covered
|
||||
match_guarded_arm!(NonEmptyStruct2(true)); //~ ERROR `NonEmptyStruct2(_)` not covered
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue