Revert warning empty patterns as unreachable

This commit is contained in:
Nadrieril 2024-08-28 20:10:26 +02:00
parent f7f8bdf2e0
commit 5b7be148ea
20 changed files with 96 additions and 465 deletions

View File

@ -951,7 +951,11 @@ impl<Cx: PatCx> PlaceInfo<Cx> {
self.is_scrutinee && matches!(ctors_for_ty, ConstructorSet::NoConstructors);
// Whether empty patterns are counted as useful or not. We only warn an empty arm unreachable if
// it is guaranteed unreachable by the opsem (i.e. if the place is `known_valid`).
let empty_arms_are_unreachable = self.validity.is_known_valid();
// We don't want to warn empty patterns as unreachable by default just yet. We will in a
// later version of rust or under a different lint name, see
// https://github.com/rust-lang/rust/pull/129103.
let empty_arms_are_unreachable = self.validity.is_known_valid()
&& (is_toplevel_exception || cx.is_exhaustive_patterns_feature_on());
// Whether empty patterns can be omitted for exhaustiveness. We ignore place validity in the
// toplevel exception and `exhaustive_patterns` cases for backwards compatibility.
let can_omit_empty_arms = self.validity.is_known_valid()

View File

@ -43,30 +43,6 @@ LL + _ => todo!(),
LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:70:9
|
LL | (_, _) => {}
| ^^^^^^ matches no values because `(u32, !)` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:76:9
|
LL | _ => {}
| ^ matches no values because `(!, !)` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:79:9
|
LL | (_, _) => {}
| ^^^^^^ matches no values because `(!, !)` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:83:9
|
@ -94,22 +70,6 @@ LL + Ok(_) => todo!(),
LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:94:9
|
LL | Err(_) => {}
| ^^^^^^ matches no values because `!` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:99:9
|
LL | Err(_) => {}
| ^^^^^^ matches no values because `!` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered
--> $DIR/empty-types.rs:96:11
|
@ -156,54 +116,6 @@ help: you might want to use `let else` to handle the variant that isn't matched
LL | let Ok(_x) = &res_u32_never else { todo!() };
| ++++++++++++++++
error: unreachable pattern
--> $DIR/empty-types.rs:112:9
|
LL | _ => {}
| ^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:115:9
|
LL | Ok(_) => {}
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:118:9
|
LL | Ok(_) => {}
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:119:9
|
LL | _ => {}
| ^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:122:9
|
LL | Ok(_) => {}
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:123:9
|
LL | Err(_) => {}
| ^^^^^^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:132:13
|
@ -220,22 +132,6 @@ LL | _ if false => {}
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:143:13
|
LL | Some(_) => {}
| ^^^^^^^ matches no values because `Void` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:147:13
|
LL | None => {}
| ---- matches all the relevant values
LL | _ => {}
| ^ no value can reach this
error[E0004]: non-exhaustive patterns: `Some(!)` not covered
--> $DIR/empty-types.rs:156:15
|
@ -303,30 +199,6 @@ LL | _ => {}
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:284:9
|
LL | (_, _) => {}
| ^^^^^^ matches no values because `(!, !)` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:287:9
|
LL | Ok(_) => {}
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:288:9
|
LL | Err(_) => {}
| ^^^^^^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error[E0005]: refutable pattern in local binding
--> $DIR/empty-types.rs:297:13
|
@ -474,30 +346,6 @@ LL + _ => todo!(),
LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:368:9
|
LL | _ => {}
| ^ matches no values because `[!; 3]` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:371:9
|
LL | [_, _, _] => {}
| ^^^^^^^^^ matches no values because `[!; 3]` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:374:9
|
LL | [_, ..] => {}
| ^^^^^^^ matches no values because `[!; 3]` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
--> $DIR/empty-types.rs:388:11
|
@ -534,40 +382,6 @@ LL ~ [..] if false => {},
LL + [] => todo!()
|
error: unreachable pattern
--> $DIR/empty-types.rs:416:9
|
LL | Some(_) => {}
| ^^^^^^^ matches no values because `!` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:421:9
|
LL | Some(_a) => {}
| ^^^^^^^^ matches no values because `!` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:426:9
|
LL | None => {}
| ---- matches all the relevant values
LL | // !useful, !reachable
LL | _ => {}
| ^ no value can reach this
error: unreachable pattern
--> $DIR/empty-types.rs:431:9
|
LL | None => {}
| ---- matches all the relevant values
LL | // !useful, !reachable
LL | _a => {}
| ^^ no value can reach this
error[E0004]: non-exhaustive patterns: `&Some(!)` not covered
--> $DIR/empty-types.rs:451:11
|
@ -744,7 +558,7 @@ LL ~ None => {},
LL + Some(!)
|
error: aborting due to 65 previous errors; 1 warning emitted
error: aborting due to 42 previous errors; 1 warning emitted
Some errors have detailed explanations: E0004, E0005.
For more information about an error, try `rustc --explain E0004`.

View File

@ -34,30 +34,6 @@ LL + _ => todo!(),
LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:70:9
|
LL | (_, _) => {}
| ^^^^^^ matches no values because `(u32, !)` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:76:9
|
LL | _ => {}
| ^ matches no values because `(!, !)` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:79:9
|
LL | (_, _) => {}
| ^^^^^^ matches no values because `(!, !)` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:83:9
|
@ -85,22 +61,6 @@ LL + Ok(_) => todo!(),
LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:94:9
|
LL | Err(_) => {}
| ^^^^^^ matches no values because `!` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:99:9
|
LL | Err(_) => {}
| ^^^^^^ matches no values because `!` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered
--> $DIR/empty-types.rs:96:11
|
@ -147,54 +107,6 @@ help: you might want to use `let else` to handle the variant that isn't matched
LL | let Ok(_x) = &res_u32_never else { todo!() };
| ++++++++++++++++
error: unreachable pattern
--> $DIR/empty-types.rs:112:9
|
LL | _ => {}
| ^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:115:9
|
LL | Ok(_) => {}
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:118:9
|
LL | Ok(_) => {}
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:119:9
|
LL | _ => {}
| ^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:122:9
|
LL | Ok(_) => {}
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:123:9
|
LL | Err(_) => {}
| ^^^^^^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:132:13
|
@ -211,22 +123,6 @@ LL | _ if false => {}
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:143:13
|
LL | Some(_) => {}
| ^^^^^^^ matches no values because `Void` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:147:13
|
LL | None => {}
| ---- matches all the relevant values
LL | _ => {}
| ^ no value can reach this
error[E0004]: non-exhaustive patterns: `Some(_)` not covered
--> $DIR/empty-types.rs:156:15
|
@ -294,30 +190,6 @@ LL | _ => {}
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:284:9
|
LL | (_, _) => {}
| ^^^^^^ matches no values because `(!, !)` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:287:9
|
LL | Ok(_) => {}
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:288:9
|
LL | Err(_) => {}
| ^^^^^^ matches no values because `Result<!, !>` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error[E0005]: refutable pattern in local binding
--> $DIR/empty-types.rs:297:13
|
@ -465,30 +337,6 @@ LL + _ => todo!(),
LL + }
|
error: unreachable pattern
--> $DIR/empty-types.rs:368:9
|
LL | _ => {}
| ^ matches no values because `[!; 3]` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:371:9
|
LL | [_, _, _] => {}
| ^^^^^^^^^ matches no values because `[!; 3]` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:374:9
|
LL | [_, ..] => {}
| ^^^^^^^ matches no values because `[!; 3]` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
--> $DIR/empty-types.rs:388:11
|
@ -525,40 +373,6 @@ LL ~ [..] if false => {},
LL + [] => todo!()
|
error: unreachable pattern
--> $DIR/empty-types.rs:416:9
|
LL | Some(_) => {}
| ^^^^^^^ matches no values because `!` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:421:9
|
LL | Some(_a) => {}
| ^^^^^^^^ matches no values because `!` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/empty-types.rs:426:9
|
LL | None => {}
| ---- matches all the relevant values
LL | // !useful, !reachable
LL | _ => {}
| ^ no value can reach this
error: unreachable pattern
--> $DIR/empty-types.rs:431:9
|
LL | None => {}
| ---- matches all the relevant values
LL | // !useful, !reachable
LL | _a => {}
| ^^ no value can reach this
error[E0004]: non-exhaustive patterns: `&Some(_)` not covered
--> $DIR/empty-types.rs:451:11
|
@ -735,7 +549,7 @@ LL ~ None => {},
LL + Some(_) => todo!()
|
error: aborting due to 65 previous errors
error: aborting due to 42 previous errors
Some errors have detailed explanations: E0004, E0005.
For more information about an error, try `rustc --explain E0004`.

View File

@ -67,16 +67,16 @@ fn basic(x: NeverBundle) {
let tuple_half_never: (u32, !) = x.tuple_half_never;
match tuple_half_never {}
match tuple_half_never {
(_, _) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
(_, _) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
let tuple_never: (!, !) = x.tuple_never;
match tuple_never {}
match tuple_never {
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
_ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
match tuple_never {
(_, _) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
(_, _) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
match tuple_never.0 {}
match tuple_never.0 {
@ -91,12 +91,12 @@ fn basic(x: NeverBundle) {
}
match res_u32_never {
Ok(_) => {}
Err(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
Err(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
match res_u32_never {
//~^ ERROR non-exhaustive
Ok(0) => {}
Err(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
Err(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
let Ok(_x) = res_u32_never;
let Ok(_x) = res_u32_never.as_ref();
@ -109,18 +109,18 @@ fn basic(x: NeverBundle) {
let result_never: Result<!, !> = x.result_never;
match result_never {}
match result_never {
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
_ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
match result_never {
Ok(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
Ok(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
match result_never {
Ok(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
Ok(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
_ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
match result_never {
Ok(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
Err(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
Ok(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
Err(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
}
@ -140,11 +140,11 @@ fn void_same_as_never(x: NeverBundle) {
}
match opt_void {
None => {}
Some(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
Some(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
match opt_void {
None => {}
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
_ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
let ref_void: &Void = &x.void;
@ -281,11 +281,11 @@ fn nested_validity_tracking(bundle: NeverBundle) {
_ => {} //~ ERROR unreachable pattern
}
match tuple_never {
(_, _) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
(_, _) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
match result_never {
Ok(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
Err(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
Ok(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
Err(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
// These should be considered !known_valid and not warn unreachable.
@ -365,13 +365,13 @@ fn arrays_and_slices(x: NeverBundle) {
let array_3_never: [!; 3] = x.array_3_never;
match array_3_never {}
match array_3_never {
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
_ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
match array_3_never {
[_, _, _] => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
[_, _, _] => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
match array_3_never {
[_, ..] => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
[_, ..] => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
let ref_array_3_never: &[!; 3] = &array_3_never;
@ -413,22 +413,22 @@ fn bindings(x: NeverBundle) {
match opt_never {
None => {}
// !useful, !reachable
Some(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
Some(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
match opt_never {
None => {}
// !useful, !reachable
Some(_a) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
Some(_a) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
match opt_never {
None => {}
// !useful, !reachable
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
_ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
match opt_never {
None => {}
// !useful, !reachable
_a => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
_a => {} //[exhaustive_patterns]~ ERROR unreachable pattern
}
// The scrutinee is known_valid, but under the `&` isn't anymore.

View File

@ -1,4 +1,5 @@
#![feature(never_type)]
#![feature(exhaustive_patterns)]
#![deny(unreachable_patterns)]
//~^ NOTE lint level is defined here

View File

@ -1,5 +1,5 @@
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:10:9
--> $DIR/explain-unreachable-pats.rs:11:9
|
LL | (1 | 2,) => {}
| -------- matches all the relevant values
@ -8,19 +8,19 @@ LL | (2,) => {}
| ^^^^ no value can reach this
|
note: the lint level is defined here
--> $DIR/explain-unreachable-pats.rs:2:9
--> $DIR/explain-unreachable-pats.rs:3:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:21:9
--> $DIR/explain-unreachable-pats.rs:22:9
|
LL | (1 | 2,) => {}
| ^^^^^^^^ no value can reach this
|
note: multiple earlier patterns match some of the same values
--> $DIR/explain-unreachable-pats.rs:21:9
--> $DIR/explain-unreachable-pats.rs:22:9
|
LL | (1,) => {}
| ---- matches some of the same values
@ -32,13 +32,13 @@ LL | (1 | 2,) => {}
| ^^^^^^^^ collectively making this unreachable
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:40:9
--> $DIR/explain-unreachable-pats.rs:41:9
|
LL | 1 ..= 6 => {}
| ^^^^^^^ no value can reach this
|
note: multiple earlier patterns match some of the same values
--> $DIR/explain-unreachable-pats.rs:40:9
--> $DIR/explain-unreachable-pats.rs:41:9
|
LL | 1 => {}
| - matches some of the same values
@ -56,7 +56,7 @@ LL | 1 ..= 6 => {}
| ^^^^^^^ ...and 2 other patterns collectively make this unreachable
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:51:9
--> $DIR/explain-unreachable-pats.rs:52:9
|
LL | Err(_) => {}
| ^^^^^^ matches no values because `!` is uninhabited
@ -64,7 +64,7 @@ LL | Err(_) => {}
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:65:9
--> $DIR/explain-unreachable-pats.rs:66:9
|
LL | (Err(_), Err(_)) => {}
| ^^^^^^^^^^^^^^^^ matches no values because `Void2` is uninhabited
@ -72,7 +72,7 @@ LL | (Err(_), Err(_)) => {}
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:72:9
--> $DIR/explain-unreachable-pats.rs:73:9
|
LL | (Err(_), Err(_)) => {}
| ^^^^^^^^^^^^^^^^ matches no values because `Void1` is uninhabited
@ -80,7 +80,7 @@ LL | (Err(_), Err(_)) => {}
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:82:11
--> $DIR/explain-unreachable-pats.rs:83:11
|
LL | if let (0
| - matches all the relevant values
@ -89,13 +89,13 @@ LL | | 0, _) = (0, 0) {}
| ^ no value can reach this
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:92:9
--> $DIR/explain-unreachable-pats.rs:93:9
|
LL | (_, true) => {}
| ^^^^^^^^^ no value can reach this
|
note: multiple earlier patterns match some of the same values
--> $DIR/explain-unreachable-pats.rs:92:9
--> $DIR/explain-unreachable-pats.rs:93:9
|
LL | (true, _) => {}
| --------- matches some of the same values
@ -107,7 +107,7 @@ LL | (_, true) => {}
| ^^^^^^^^^ collectively making this unreachable
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:105:9
--> $DIR/explain-unreachable-pats.rs:106:9
|
LL | (true, _) => {}
| --------- matches all the relevant values
@ -116,7 +116,7 @@ LL | (true, true) => {}
| ^^^^^^^^^^^^ no value can reach this
error: unreachable pattern
--> $DIR/explain-unreachable-pats.rs:117:9
--> $DIR/explain-unreachable-pats.rs:118:9
|
LL | (_, true, 0..10) => {}
| ---------------- matches all the relevant values

View File

@ -1,6 +1,7 @@
#![feature(never_type)]
#![feature(type_alias_impl_trait)]
#![feature(non_exhaustive_omitted_patterns_lint)]
#![feature(exhaustive_patterns)]
#![deny(unreachable_patterns)]
// Test that the lint traversal handles opaques correctly
#![deny(non_exhaustive_omitted_patterns)]

View File

@ -1,18 +1,18 @@
error: unreachable pattern
--> $DIR/impl-trait.rs:16:13
--> $DIR/impl-trait.rs:17:13
|
LL | _ => {}
| ^ matches no values because `Void` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
note: the lint level is defined here
--> $DIR/impl-trait.rs:4:9
--> $DIR/impl-trait.rs:5:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/impl-trait.rs:30:13
--> $DIR/impl-trait.rs:31:13
|
LL | _ => {}
| ^ matches no values because `Void` is uninhabited
@ -20,7 +20,7 @@ LL | _ => {}
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/impl-trait.rs:44:13
--> $DIR/impl-trait.rs:45:13
|
LL | Some(_) => {}
| ^^^^^^^ matches no values because `Void` is uninhabited
@ -28,7 +28,7 @@ LL | Some(_) => {}
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/impl-trait.rs:48:13
--> $DIR/impl-trait.rs:49:13
|
LL | None => {}
| ---- matches all the relevant values
@ -36,7 +36,7 @@ LL | _ => {}
| ^ no value can reach this
error: unreachable pattern
--> $DIR/impl-trait.rs:58:13
--> $DIR/impl-trait.rs:59:13
|
LL | Some(_) => {}
| ^^^^^^^ matches no values because `Void` is uninhabited
@ -44,7 +44,7 @@ LL | Some(_) => {}
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/impl-trait.rs:62:13
--> $DIR/impl-trait.rs:63:13
|
LL | None => {}
| ---- matches all the relevant values
@ -52,7 +52,7 @@ LL | _ => {}
| ^ no value can reach this
error: unreachable pattern
--> $DIR/impl-trait.rs:75:9
--> $DIR/impl-trait.rs:76:9
|
LL | _ => {}
| ^ matches no values because `Void` is uninhabited
@ -60,7 +60,7 @@ LL | _ => {}
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/impl-trait.rs:85:9
--> $DIR/impl-trait.rs:86:9
|
LL | _ => {}
| - matches any value
@ -68,7 +68,7 @@ LL | Some((a, b)) => {}
| ^^^^^^^^^^^^ no value can reach this
error: unreachable pattern
--> $DIR/impl-trait.rs:93:13
--> $DIR/impl-trait.rs:94:13
|
LL | _ => {}
| ^ matches no values because `Void` is uninhabited
@ -76,7 +76,7 @@ LL | _ => {}
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/impl-trait.rs:104:9
--> $DIR/impl-trait.rs:105:9
|
LL | Some((a, b)) => {}
| ------------ matches all the relevant values
@ -84,7 +84,7 @@ LL | Some((mut x, mut y)) => {
| ^^^^^^^^^^^^^^^^^^^^ no value can reach this
error: unreachable pattern
--> $DIR/impl-trait.rs:123:13
--> $DIR/impl-trait.rs:124:13
|
LL | _ => {}
| - matches any value
@ -92,7 +92,7 @@ LL | Rec { n: 0, w: Some(Rec { n: 0, w: _ }) } => {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no value can reach this
error: unreachable pattern
--> $DIR/impl-trait.rs:137:13
--> $DIR/impl-trait.rs:138:13
|
LL | _ => {}
| ^ matches no values because `SecretelyVoid` is uninhabited
@ -100,7 +100,7 @@ LL | _ => {}
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/impl-trait.rs:150:13
--> $DIR/impl-trait.rs:151:13
|
LL | _ => {}
| ^ matches no values because `SecretelyDoubleVoid` is uninhabited
@ -108,7 +108,7 @@ LL | _ => {}
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error[E0004]: non-exhaustive patterns: type `impl Copy` is non-empty
--> $DIR/impl-trait.rs:22:11
--> $DIR/impl-trait.rs:23:11
|
LL | match return_never_rpit(x) {}
| ^^^^^^^^^^^^^^^^^^^^
@ -122,7 +122,7 @@ LL + }
|
error[E0004]: non-exhaustive patterns: type `T` is non-empty
--> $DIR/impl-trait.rs:36:11
--> $DIR/impl-trait.rs:37:11
|
LL | match return_never_tait(x) {}
| ^^^^^^^^^^^^^^^^^^^^

View File

@ -1,3 +1,4 @@
#![feature(exhaustive_patterns)]
#![feature(never_type, never_type_fallback)]
#![allow(unreachable_code)]
#![deny(unreachable_patterns)]

View File

@ -1,12 +1,12 @@
error: unreachable pattern
--> $DIR/unreachable-loop-patterns.rs:16:9
--> $DIR/unreachable-loop-patterns.rs:17:9
|
LL | for _ in unimplemented!() as Void {}
| ^ matches no values because `Void` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
note: the lint level is defined here
--> $DIR/unreachable-loop-patterns.rs:3:9
--> $DIR/unreachable-loop-patterns.rs:4:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^

View File

@ -1,3 +1,4 @@
#![feature(exhaustive_patterns)]
#![feature(never_patterns)]
#![allow(incomplete_features)]
#![allow(dead_code, unreachable_code)]

View File

@ -1,18 +1,18 @@
error: unreachable pattern
--> $DIR/unreachable.rs:14:9
--> $DIR/unreachable.rs:15:9
|
LL | Err(!),
| ^^^^^^ matches no values because `Void` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
note: the lint level is defined here
--> $DIR/unreachable.rs:4:9
--> $DIR/unreachable.rs:5:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/unreachable.rs:17:19
--> $DIR/unreachable.rs:18:19
|
LL | let (Ok(_x) | Err(!)) = res_void;
| ^^^^^^ matches no values because `Void` is uninhabited
@ -20,7 +20,7 @@ LL | let (Ok(_x) | Err(!)) = res_void;
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/unreachable.rs:19:12
--> $DIR/unreachable.rs:20:12
|
LL | if let Err(!) = res_void {}
| ^^^^^^ matches no values because `Void` is uninhabited
@ -28,7 +28,7 @@ LL | if let Err(!) = res_void {}
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/unreachable.rs:21:24
--> $DIR/unreachable.rs:22:24
|
LL | if let (Ok(true) | Err(!)) = res_void {}
| ^^^^^^ matches no values because `Void` is uninhabited
@ -36,7 +36,7 @@ LL | if let (Ok(true) | Err(!)) = res_void {}
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/unreachable.rs:23:23
--> $DIR/unreachable.rs:24:23
|
LL | for (Ok(mut _x) | Err(!)) in [res_void] {}
| ^^^^^^ matches no values because `Void` is uninhabited
@ -44,7 +44,7 @@ LL | for (Ok(mut _x) | Err(!)) in [res_void] {}
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/unreachable.rs:27:18
--> $DIR/unreachable.rs:28:18
|
LL | fn foo((Ok(_x) | Err(!)): Result<bool, Void>) {}
| ^^^^^^ matches no values because `Void` is uninhabited

View File

@ -12,7 +12,6 @@ use uninhabited::PartiallyInhabitedVariants;
pub fn foo(x: PartiallyInhabitedVariants) {
match x {
PartiallyInhabitedVariants::Struct { .. } => {}
//~^ ERROR unreachable pattern
PartiallyInhabitedVariants::Struct { .. } => {}
//~^ ERROR unreachable pattern
_ => {}

View File

@ -1,23 +1,16 @@
error: unreachable pattern
--> $DIR/issue-65157-repeated-match-arm.rs:14:9
--> $DIR/issue-65157-repeated-match-arm.rs:15:9
|
LL | PartiallyInhabitedVariants::Struct { .. } => {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `PartiallyInhabitedVariants` is uninhabited
| ----------------------------------------- matches all the relevant values
LL | PartiallyInhabitedVariants::Struct { .. } => {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no value can reach this
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
note: the lint level is defined here
--> $DIR/issue-65157-repeated-match-arm.rs:2:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/issue-65157-repeated-match-arm.rs:16:9
|
LL | PartiallyInhabitedVariants::Struct { .. } => {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `PartiallyInhabitedVariants` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: aborting due to 2 previous errors
error: aborting due to 1 previous error

View File

@ -1,4 +1,5 @@
//@ aux-build:uninhabited.rs
#![feature(exhaustive_patterns)]
#![deny(unreachable_patterns)]
extern crate uninhabited;

View File

@ -1,18 +1,18 @@
error: unreachable pattern
--> $DIR/patterns.rs:41:9
--> $DIR/patterns.rs:42:9
|
LL | Some(_x) => (),
| ^^^^^^^^ matches no values because `UninhabitedVariants` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
note: the lint level is defined here
--> $DIR/patterns.rs:2:9
--> $DIR/patterns.rs:3:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/patterns.rs:46:15
--> $DIR/patterns.rs:47:15
|
LL | while let PartiallyInhabitedVariants::Struct { x, .. } = partially_inhabited_variant() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `!` is uninhabited
@ -20,7 +20,7 @@ LL | while let PartiallyInhabitedVariants::Struct { x, .. } = partially_inha
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/patterns.rs:48:15
--> $DIR/patterns.rs:49:15
|
LL | while let Some(_x) = uninhabited_struct() {
| ^^^^^^^^ matches no values because `UninhabitedStruct` is uninhabited
@ -28,7 +28,7 @@ LL | while let Some(_x) = uninhabited_struct() {
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/patterns.rs:51:15
--> $DIR/patterns.rs:52:15
|
LL | while let Some(_x) = uninhabited_tuple_struct() {
| ^^^^^^^^ matches no values because `UninhabitedTupleStruct` is uninhabited

View File

@ -1,3 +1,4 @@
#![feature(exhaustive_patterns)]
#![deny(unreachable_patterns)]
#![feature(never_type)]

View File

@ -1,18 +1,18 @@
error: unreachable pattern
--> $DIR/patterns_same_crate.rs:52:9
--> $DIR/patterns_same_crate.rs:53:9
|
LL | Some(_x) => (),
| ^^^^^^^^ matches no values because `UninhabitedEnum` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
note: the lint level is defined here
--> $DIR/patterns_same_crate.rs:1:9
--> $DIR/patterns_same_crate.rs:2:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/patterns_same_crate.rs:57:9
--> $DIR/patterns_same_crate.rs:58:9
|
LL | Some(_x) => (),
| ^^^^^^^^ matches no values because `UninhabitedVariants` is uninhabited
@ -20,7 +20,7 @@ LL | Some(_x) => (),
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/patterns_same_crate.rs:61:15
--> $DIR/patterns_same_crate.rs:62:15
|
LL | while let PartiallyInhabitedVariants::Struct { x } = partially_inhabited_variant() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `!` is uninhabited
@ -28,7 +28,7 @@ LL | while let PartiallyInhabitedVariants::Struct { x } = partially_inhabite
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/patterns_same_crate.rs:65:15
--> $DIR/patterns_same_crate.rs:66:15
|
LL | while let Some(_x) = uninhabited_struct() {
| ^^^^^^^^ matches no values because `UninhabitedStruct` is uninhabited
@ -36,7 +36,7 @@ LL | while let Some(_x) = uninhabited_struct() {
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/patterns_same_crate.rs:68:15
--> $DIR/patterns_same_crate.rs:69:15
|
LL | while let Some(_x) = uninhabited_tuple_struct() {
| ^^^^^^^^ matches no values because `UninhabitedTupleStruct` is uninhabited

View File

@ -1,3 +1,4 @@
#![feature(exhaustive_patterns)]
#![feature(box_patterns)]
#![feature(never_type)]
#![deny(unreachable_patterns)]

View File

@ -1,18 +1,18 @@
error: unreachable pattern
--> $DIR/uninhabited-patterns.rs:29:9
--> $DIR/uninhabited-patterns.rs:30:9
|
LL | Ok(box _) => (),
| ^^^^^^^^^ matches no values because `NotSoSecretlyEmpty` is uninhabited
|
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
note: the lint level is defined here
--> $DIR/uninhabited-patterns.rs:3:9
--> $DIR/uninhabited-patterns.rs:4:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
--> $DIR/uninhabited-patterns.rs:38:9
--> $DIR/uninhabited-patterns.rs:39:9
|
LL | Err(Ok(_y)) => (),
| ^^^^^^^^^^^ matches no values because `NotSoSecretlyEmpty` is uninhabited
@ -20,7 +20,7 @@ LL | Err(Ok(_y)) => (),
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
error: unreachable pattern
--> $DIR/uninhabited-patterns.rs:41:15
--> $DIR/uninhabited-patterns.rs:42:15
|
LL | while let Some(_y) = foo() {
| ^^^^^^^^ matches no values because `NotSoSecretlyEmpty` is uninhabited