From 5b7be148ea0128daad309cf5a123c868a65d7737 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 28 Aug 2024 20:10:26 +0200 Subject: [PATCH] Revert warning empty patterns as unreachable --- .../rustc_pattern_analysis/src/usefulness.rs | 6 +- .../usefulness/empty-types.never_pats.stderr | 188 +----------------- .../usefulness/empty-types.normal.stderr | 188 +----------------- tests/ui/pattern/usefulness/empty-types.rs | 46 ++--- .../usefulness/explain-unreachable-pats.rs | 1 + .../explain-unreachable-pats.stderr | 28 +-- tests/ui/pattern/usefulness/impl-trait.rs | 1 + tests/ui/pattern/usefulness/impl-trait.stderr | 32 +-- .../ui/reachable/unreachable-loop-patterns.rs | 1 + .../unreachable-loop-patterns.stderr | 4 +- .../rfc-0000-never_patterns/unreachable.rs | 1 + .../unreachable.stderr | 14 +- .../issue-65157-repeated-match-arm.rs | 1 - .../issue-65157-repeated-match-arm.stderr | 17 +- .../uninhabited/patterns.rs | 1 + .../uninhabited/patterns.stderr | 10 +- .../uninhabited/patterns_same_crate.rs | 1 + .../uninhabited/patterns_same_crate.stderr | 12 +- tests/ui/uninhabited/uninhabited-patterns.rs | 1 + .../uninhabited/uninhabited-patterns.stderr | 8 +- 20 files changed, 96 insertions(+), 465 deletions(-) diff --git a/compiler/rustc_pattern_analysis/src/usefulness.rs b/compiler/rustc_pattern_analysis/src/usefulness.rs index 6535afcc39862..814559a66c568 100644 --- a/compiler/rustc_pattern_analysis/src/usefulness.rs +++ b/compiler/rustc_pattern_analysis/src/usefulness.rs @@ -951,7 +951,11 @@ impl PlaceInfo { 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() diff --git a/tests/ui/pattern/usefulness/empty-types.never_pats.stderr b/tests/ui/pattern/usefulness/empty-types.never_pats.stderr index 68213a2d661e0..fe9c431982004 100644 --- a/tests/ui/pattern/usefulness/empty-types.never_pats.stderr +++ b/tests/ui/pattern/usefulness/empty-types.never_pats.stderr @@ -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`. diff --git a/tests/ui/pattern/usefulness/empty-types.normal.stderr b/tests/ui/pattern/usefulness/empty-types.normal.stderr index 8f60dad4467bc..201b0b5c3fde3 100644 --- a/tests/ui/pattern/usefulness/empty-types.normal.stderr +++ b/tests/ui/pattern/usefulness/empty-types.normal.stderr @@ -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`. diff --git a/tests/ui/pattern/usefulness/empty-types.rs b/tests/ui/pattern/usefulness/empty-types.rs index d561a0e9c128b..9e5f273a39052 100644 --- a/tests/ui/pattern/usefulness/empty-types.rs +++ b/tests/ui/pattern/usefulness/empty-types.rs @@ -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. diff --git a/tests/ui/pattern/usefulness/explain-unreachable-pats.rs b/tests/ui/pattern/usefulness/explain-unreachable-pats.rs index 1cfa5212414bb..f1af7f294cbd8 100644 --- a/tests/ui/pattern/usefulness/explain-unreachable-pats.rs +++ b/tests/ui/pattern/usefulness/explain-unreachable-pats.rs @@ -1,4 +1,5 @@ #![feature(never_type)] +#![feature(exhaustive_patterns)] #![deny(unreachable_patterns)] //~^ NOTE lint level is defined here diff --git a/tests/ui/pattern/usefulness/explain-unreachable-pats.stderr b/tests/ui/pattern/usefulness/explain-unreachable-pats.stderr index 7023c2775e9a7..67f83a8517504 100644 --- a/tests/ui/pattern/usefulness/explain-unreachable-pats.stderr +++ b/tests/ui/pattern/usefulness/explain-unreachable-pats.stderr @@ -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 diff --git a/tests/ui/pattern/usefulness/impl-trait.rs b/tests/ui/pattern/usefulness/impl-trait.rs index c1cc279f74ce9..16560a092675f 100644 --- a/tests/ui/pattern/usefulness/impl-trait.rs +++ b/tests/ui/pattern/usefulness/impl-trait.rs @@ -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)] diff --git a/tests/ui/pattern/usefulness/impl-trait.stderr b/tests/ui/pattern/usefulness/impl-trait.stderr index 34b157f0fc443..f2945fca82bed 100644 --- a/tests/ui/pattern/usefulness/impl-trait.stderr +++ b/tests/ui/pattern/usefulness/impl-trait.stderr @@ -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) {} | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/reachable/unreachable-loop-patterns.rs b/tests/ui/reachable/unreachable-loop-patterns.rs index d074e3a6ece4b..9be37ecf2bb27 100644 --- a/tests/ui/reachable/unreachable-loop-patterns.rs +++ b/tests/ui/reachable/unreachable-loop-patterns.rs @@ -1,3 +1,4 @@ +#![feature(exhaustive_patterns)] #![feature(never_type, never_type_fallback)] #![allow(unreachable_code)] #![deny(unreachable_patterns)] diff --git a/tests/ui/reachable/unreachable-loop-patterns.stderr b/tests/ui/reachable/unreachable-loop-patterns.stderr index 03959ac160695..290f45700b2e4 100644 --- a/tests/ui/reachable/unreachable-loop-patterns.stderr +++ b/tests/ui/reachable/unreachable-loop-patterns.stderr @@ -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)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/unreachable.rs b/tests/ui/rfcs/rfc-0000-never_patterns/unreachable.rs index f68da4aa17316..6d7815f7a9eb0 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/unreachable.rs +++ b/tests/ui/rfcs/rfc-0000-never_patterns/unreachable.rs @@ -1,3 +1,4 @@ +#![feature(exhaustive_patterns)] #![feature(never_patterns)] #![allow(incomplete_features)] #![allow(dead_code, unreachable_code)] diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/unreachable.stderr b/tests/ui/rfcs/rfc-0000-never_patterns/unreachable.stderr index 6b3f303eeab84..90874760a56fa 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/unreachable.stderr +++ b/tests/ui/rfcs/rfc-0000-never_patterns/unreachable.stderr @@ -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) {} | ^^^^^^ matches no values because `Void` is uninhabited diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs index 6bee019e89782..ca7c528715420 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs @@ -12,7 +12,6 @@ use uninhabited::PartiallyInhabitedVariants; pub fn foo(x: PartiallyInhabitedVariants) { match x { PartiallyInhabitedVariants::Struct { .. } => {} - //~^ ERROR unreachable pattern PartiallyInhabitedVariants::Struct { .. } => {} //~^ ERROR unreachable pattern _ => {} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr index 4fa53101a55f1..86df9ef9b564c 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr @@ -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 diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs index edc588777eb98..088331b0e7f72 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs @@ -1,4 +1,5 @@ //@ aux-build:uninhabited.rs +#![feature(exhaustive_patterns)] #![deny(unreachable_patterns)] extern crate uninhabited; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.stderr index deaa2ffd92720..83300049ea9b4 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.stderr @@ -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 diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs index 58cced3d23d61..3d89ca15d3778 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs @@ -1,3 +1,4 @@ +#![feature(exhaustive_patterns)] #![deny(unreachable_patterns)] #![feature(never_type)] diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr index 38524bf5b952e..4b107b0364506 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr @@ -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 diff --git a/tests/ui/uninhabited/uninhabited-patterns.rs b/tests/ui/uninhabited/uninhabited-patterns.rs index 988383e691b4e..b7429464fa5a0 100644 --- a/tests/ui/uninhabited/uninhabited-patterns.rs +++ b/tests/ui/uninhabited/uninhabited-patterns.rs @@ -1,3 +1,4 @@ +#![feature(exhaustive_patterns)] #![feature(box_patterns)] #![feature(never_type)] #![deny(unreachable_patterns)] diff --git a/tests/ui/uninhabited/uninhabited-patterns.stderr b/tests/ui/uninhabited/uninhabited-patterns.stderr index 0e1c9d31a731f..db0166ad5f2c5 100644 --- a/tests/ui/uninhabited/uninhabited-patterns.stderr +++ b/tests/ui/uninhabited/uninhabited-patterns.stderr @@ -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