Tweak diagnostic for consistency

This commit is contained in:
Nadrieril 2023-10-29 04:43:25 +01:00
parent 380c56c6b3
commit d95f6a9532
6 changed files with 129 additions and 79 deletions

View File

@ -1033,11 +1033,9 @@ fn adt_defined_here<'p, 'tcx>(
let ty = ty.peel_refs();
if let ty::Adt(def, _) = ty.kind() {
let mut spans = vec![];
if witnesses.len() < 5 {
for sp in maybe_point_at_variant(cx, *def, witnesses.iter()) {
for sp in maybe_point_at_variant(cx, *def, witnesses.iter().take(5)) {
spans.push(sp);
}
}
let def_span = cx
.tcx
.hir()

View File

@ -1,5 +1,5 @@
error: unreachable pattern
--> $DIR/empty-match.rs:58:9
--> $DIR/empty-match.rs:68:9
|
LL | _ => {},
| ^
@ -10,26 +10,26 @@ note: the lint level is defined here
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/empty-match.rs:61:9
|
LL | _ if false => {},
| ^
error: unreachable pattern
--> $DIR/empty-match.rs:68:9
|
LL | _ => {},
| ^
error: unreachable pattern
--> $DIR/empty-match.rs:71:9
|
LL | _ if false => {},
| ^
error: unreachable pattern
--> $DIR/empty-match.rs:78:9
|
LL | _ => {},
| ^
error: unreachable pattern
--> $DIR/empty-match.rs:81:9
|
LL | _ if false => {},
| ^
error[E0005]: refutable pattern in local binding
--> $DIR/empty-match.rs:76:9
--> $DIR/empty-match.rs:86:9
|
LL | let None = x;
| ^^^^ pattern `Some(_)` not covered
@ -44,19 +44,19 @@ LL | if let None = x { todo!() };
| ++ +++++++++++
error: unreachable pattern
--> $DIR/empty-match.rs:88:9
--> $DIR/empty-match.rs:98:9
|
LL | _ => {},
| ^
error: unreachable pattern
--> $DIR/empty-match.rs:91:9
--> $DIR/empty-match.rs:101:9
|
LL | _ if false => {},
| ^
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
--> $DIR/empty-match.rs:109:20
--> $DIR/empty-match.rs:119:20
|
LL | match_no_arms!(0u8);
| ^^^
@ -65,7 +65,7 @@ LL | match_no_arms!(0u8);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct1` is non-empty
--> $DIR/empty-match.rs:111:20
--> $DIR/empty-match.rs:121:20
|
LL | match_no_arms!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^
@ -79,7 +79,7 @@ LL | struct NonEmptyStruct1;
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct2` is non-empty
--> $DIR/empty-match.rs:113:20
--> $DIR/empty-match.rs:123:20
|
LL | match_no_arms!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^
@ -93,7 +93,7 @@ LL | struct NonEmptyStruct2(bool);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty
--> $DIR/empty-match.rs:115:20
--> $DIR/empty-match.rs:125:20
|
LL | match_no_arms!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -107,7 +107,7 @@ LL | union NonEmptyUnion1 {
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty
--> $DIR/empty-match.rs:117:20
--> $DIR/empty-match.rs:127:20
|
LL | match_no_arms!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -121,7 +121,7 @@ LL | union NonEmptyUnion2 {
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
--> $DIR/empty-match.rs:119:20
--> $DIR/empty-match.rs:129:20
|
LL | match_no_arms!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
@ -137,7 +137,7 @@ LL | Foo(bool),
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
--> $DIR/empty-match.rs:122:20
--> $DIR/empty-match.rs:132:20
|
LL | match_no_arms!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
@ -156,21 +156,28 @@ LL | Bar,
= 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: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
--> $DIR/empty-match.rs:125:20
--> $DIR/empty-match.rs:135:20
|
LL | match_no_arms!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
|
note: `NonEmptyEnum5` defined here
--> $DIR/empty-match.rs:49:6
--> $DIR/empty-match.rs:50:5
|
LL | enum NonEmptyEnum5 {
| ^^^^^^^^^^^^^
| -------------
LL | V1, V2, V3, V4, V5,
| ^^ ^^ ^^ ^^ ^^ not covered
| | | | |
| | | | not covered
| | | not covered
| | not covered
| not covered
= 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
--> $DIR/empty-match.rs:129:24
--> $DIR/empty-match.rs:139:24
|
LL | match_guarded_arm!(0u8);
| ^^^ pattern `_` not covered
@ -184,7 +191,7 @@ LL + _ => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered
--> $DIR/empty-match.rs:134:24
--> $DIR/empty-match.rs:144:24
|
LL | match_guarded_arm!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered
@ -203,7 +210,7 @@ LL + NonEmptyStruct1 => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered
--> $DIR/empty-match.rs:139:24
--> $DIR/empty-match.rs:149:24
|
LL | match_guarded_arm!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered
@ -222,7 +229,7 @@ LL + NonEmptyStruct2(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered
--> $DIR/empty-match.rs:144:24
--> $DIR/empty-match.rs:154:24
|
LL | match_guarded_arm!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered
@ -241,7 +248,7 @@ LL + NonEmptyUnion1 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered
--> $DIR/empty-match.rs:149:24
--> $DIR/empty-match.rs:159:24
|
LL | match_guarded_arm!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered
@ -260,7 +267,7 @@ LL + NonEmptyUnion2 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
--> $DIR/empty-match.rs:154:24
--> $DIR/empty-match.rs:164:24
|
LL | match_guarded_arm!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
@ -281,7 +288,7 @@ LL + NonEmptyEnum1::Foo(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
--> $DIR/empty-match.rs:159:24
--> $DIR/empty-match.rs:169:24
|
LL | match_guarded_arm!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
@ -305,16 +312,23 @@ LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
--> $DIR/empty-match.rs:164:24
--> $DIR/empty-match.rs:174:24
|
LL | match_guarded_arm!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
|
note: `NonEmptyEnum5` defined here
--> $DIR/empty-match.rs:49:6
--> $DIR/empty-match.rs:50:5
|
LL | enum NonEmptyEnum5 {
| ^^^^^^^^^^^^^
| -------------
LL | V1, V2, V3, V4, V5,
| ^^ ^^ ^^ ^^ ^^ not covered
| | | | |
| | | | not covered
| | | not covered
| | not covered
| not covered
= note: the matched value is of type `NonEmptyEnum5`
= 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 as shown, or multiple match arms

View File

@ -1,5 +1,5 @@
error: unreachable pattern
--> $DIR/empty-match.rs:58:9
--> $DIR/empty-match.rs:68:9
|
LL | _ => {},
| ^
@ -10,26 +10,26 @@ note: the lint level is defined here
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/empty-match.rs:61:9
|
LL | _ if false => {},
| ^
error: unreachable pattern
--> $DIR/empty-match.rs:68:9
|
LL | _ => {},
| ^
error: unreachable pattern
--> $DIR/empty-match.rs:71:9
|
LL | _ if false => {},
| ^
error: unreachable pattern
--> $DIR/empty-match.rs:78:9
|
LL | _ => {},
| ^
error: unreachable pattern
--> $DIR/empty-match.rs:81:9
|
LL | _ if false => {},
| ^
error[E0005]: refutable pattern in local binding
--> $DIR/empty-match.rs:76:9
--> $DIR/empty-match.rs:86:9
|
LL | let None = x;
| ^^^^ pattern `Some(_)` not covered
@ -43,19 +43,19 @@ LL | if let None = x { todo!() };
| ++ +++++++++++
error: unreachable pattern
--> $DIR/empty-match.rs:88:9
--> $DIR/empty-match.rs:98:9
|
LL | _ => {},
| ^
error: unreachable pattern
--> $DIR/empty-match.rs:91:9
--> $DIR/empty-match.rs:101:9
|
LL | _ if false => {},
| ^
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
--> $DIR/empty-match.rs:109:20
--> $DIR/empty-match.rs:119:20
|
LL | match_no_arms!(0u8);
| ^^^
@ -64,7 +64,7 @@ LL | match_no_arms!(0u8);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct1` is non-empty
--> $DIR/empty-match.rs:111:20
--> $DIR/empty-match.rs:121:20
|
LL | match_no_arms!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^
@ -78,7 +78,7 @@ LL | struct NonEmptyStruct1;
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct2` is non-empty
--> $DIR/empty-match.rs:113:20
--> $DIR/empty-match.rs:123:20
|
LL | match_no_arms!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^
@ -92,7 +92,7 @@ LL | struct NonEmptyStruct2(bool);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty
--> $DIR/empty-match.rs:115:20
--> $DIR/empty-match.rs:125:20
|
LL | match_no_arms!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -106,7 +106,7 @@ LL | union NonEmptyUnion1 {
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty
--> $DIR/empty-match.rs:117:20
--> $DIR/empty-match.rs:127:20
|
LL | match_no_arms!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -120,7 +120,7 @@ LL | union NonEmptyUnion2 {
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
--> $DIR/empty-match.rs:119:20
--> $DIR/empty-match.rs:129:20
|
LL | match_no_arms!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
@ -136,7 +136,7 @@ LL | Foo(bool),
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
--> $DIR/empty-match.rs:122:20
--> $DIR/empty-match.rs:132:20
|
LL | match_no_arms!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
@ -155,21 +155,28 @@ LL | Bar,
= 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: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
--> $DIR/empty-match.rs:125:20
--> $DIR/empty-match.rs:135:20
|
LL | match_no_arms!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
|
note: `NonEmptyEnum5` defined here
--> $DIR/empty-match.rs:49:6
--> $DIR/empty-match.rs:50:5
|
LL | enum NonEmptyEnum5 {
| ^^^^^^^^^^^^^
| -------------
LL | V1, V2, V3, V4, V5,
| ^^ ^^ ^^ ^^ ^^ not covered
| | | | |
| | | | not covered
| | | not covered
| | not covered
| not covered
= 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
--> $DIR/empty-match.rs:129:24
--> $DIR/empty-match.rs:139:24
|
LL | match_guarded_arm!(0u8);
| ^^^ pattern `_` not covered
@ -183,7 +190,7 @@ LL + _ => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered
--> $DIR/empty-match.rs:134:24
--> $DIR/empty-match.rs:144:24
|
LL | match_guarded_arm!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered
@ -202,7 +209,7 @@ LL + NonEmptyStruct1 => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered
--> $DIR/empty-match.rs:139:24
--> $DIR/empty-match.rs:149:24
|
LL | match_guarded_arm!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered
@ -221,7 +228,7 @@ LL + NonEmptyStruct2(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered
--> $DIR/empty-match.rs:144:24
--> $DIR/empty-match.rs:154:24
|
LL | match_guarded_arm!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered
@ -240,7 +247,7 @@ LL + NonEmptyUnion1 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered
--> $DIR/empty-match.rs:149:24
--> $DIR/empty-match.rs:159:24
|
LL | match_guarded_arm!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered
@ -259,7 +266,7 @@ LL + NonEmptyUnion2 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
--> $DIR/empty-match.rs:154:24
--> $DIR/empty-match.rs:164:24
|
LL | match_guarded_arm!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
@ -280,7 +287,7 @@ LL + NonEmptyEnum1::Foo(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
--> $DIR/empty-match.rs:159:24
--> $DIR/empty-match.rs:169:24
|
LL | match_guarded_arm!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
@ -304,16 +311,23 @@ LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
--> $DIR/empty-match.rs:164:24
--> $DIR/empty-match.rs:174:24
|
LL | match_guarded_arm!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
|
note: `NonEmptyEnum5` defined here
--> $DIR/empty-match.rs:49:6
--> $DIR/empty-match.rs:50:5
|
LL | enum NonEmptyEnum5 {
| ^^^^^^^^^^^^^
| -------------
LL | V1, V2, V3, V4, V5,
| ^^ ^^ ^^ ^^ ^^ not covered
| | | | |
| | | | not covered
| | | not covered
| | not covered
| not covered
= note: the matched value is of type `NonEmptyEnum5`
= 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 as shown, or multiple match arms

View File

@ -47,9 +47,19 @@ enum NonEmptyEnum2 {
//~| NOTE not covered
}
enum NonEmptyEnum5 {
V1, V2, V3, V4, V5,
//~^ NOTE `NonEmptyEnum5` defined here
//~| NOTE `NonEmptyEnum5` defined here
V1, V2, V3, V4, V5,
//~| NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
}
fn empty_enum(x: EmptyEnum) {

View File

@ -107,6 +107,9 @@ LL | match Some(A) {
|
note: `Option<Enum>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL
::: $SRC_DIR/core/src/option.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Option<Enum>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms
|

View File

@ -68,10 +68,21 @@ LL | match ExcessiveEnum::First {
| ^^^^^^^^^^^^^^^^^^^^ patterns `ExcessiveEnum::Second`, `ExcessiveEnum::Third`, `ExcessiveEnum::Fourth` and 8 more not covered
|
note: `ExcessiveEnum` defined here
--> $DIR/non-exhaustive-pattern-witness.rs:44:6
--> $DIR/non-exhaustive-pattern-witness.rs:46:5
|
LL | enum ExcessiveEnum {
| ^^^^^^^^^^^^^
| -------------
LL | First,
LL | Second,
| ^^^^^^ not covered
LL | Third,
| ^^^^^ not covered
LL | Fourth,
| ^^^^^^ not covered
LL | Fifth,
| ^^^^^ not covered
LL | Sixth,
| ^^^^^ not covered
= note: the matched value is of type `ExcessiveEnum`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms
|