From 622bfdb2fdfc3da9ca2959b5e9ae686b1c9ed249 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 2 Dec 2020 20:24:20 +0000 Subject: [PATCH] Deduplicate some tests using revisions --- ...=> empty-match.exhaustive_patterns.stderr} | 46 +++---- ...empty.stderr => empty-match.normal.stderr} | 42 +++---- ...-exhaustive_patterns.rs => empty-match.rs} | 7 +- .../integer-ranges/pointer-sized-int-deny.rs | 48 ------- ....stderr => pointer-sized-int.allow.stderr} | 2 +- ...y.stderr => pointer-sized-int.deny.stderr} | 24 ++-- ...ized-int-allow.rs => pointer-sized-int.rs} | 14 ++- src/test/ui/pattern/usefulness/match-empty.rs | 118 ------------------ 8 files changed, 74 insertions(+), 227 deletions(-) rename src/test/ui/pattern/usefulness/{match-empty-exhaustive_patterns.stderr => empty-match.exhaustive_patterns.stderr} (86%) rename src/test/ui/pattern/usefulness/{match-empty.stderr => empty-match.normal.stderr} (91%) rename src/test/ui/pattern/usefulness/{match-empty-exhaustive_patterns.rs => empty-match.rs} (91%) delete mode 100644 src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-deny.rs rename src/test/ui/pattern/usefulness/integer-ranges/{pointer-sized-int-allow.stderr => pointer-sized-int.allow.stderr} (89%) rename src/test/ui/pattern/usefulness/integer-ranges/{pointer-sized-int-deny.stderr => pointer-sized-int.deny.stderr} (92%) rename src/test/ui/pattern/usefulness/integer-ranges/{pointer-sized-int-allow.rs => pointer-sized-int.rs} (60%) delete mode 100644 src/test/ui/pattern/usefulness/match-empty.rs diff --git a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr b/src/test/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr similarity index 86% rename from src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr rename to src/test/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr index 9d8b5f38e8c..a5c8af1f814 100644 --- a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr +++ b/src/test/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr @@ -1,59 +1,59 @@ error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:52:9 + --> $DIR/empty-match.rs:53:9 | LL | _ => {}, | ^ | note: the lint level is defined here - --> $DIR/match-empty-exhaustive_patterns.rs:5:9 + --> $DIR/empty-match.rs:6:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:55:9 + --> $DIR/empty-match.rs:56:9 | LL | _ if false => {}, | ^ error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:62:9 + --> $DIR/empty-match.rs:63:9 | LL | _ => {}, | ^ error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:65:9 + --> $DIR/empty-match.rs:66:9 | LL | _ if false => {}, | ^ error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:72:9 + --> $DIR/empty-match.rs:73:9 | LL | _ => {}, | ^ error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:75:9 + --> $DIR/empty-match.rs:76:9 | LL | _ if false => {}, | ^ error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:82:9 + --> $DIR/empty-match.rs:83:9 | LL | Some(_) => {} | ^^^^^^^ error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:86:9 + --> $DIR/empty-match.rs:87:9 | LL | Some(_) => {} | ^^^^^^^ error[E0004]: non-exhaustive patterns: type `u8` is non-empty - --> $DIR/match-empty-exhaustive_patterns.rs:89:18 + --> $DIR/empty-match.rs:90:18 | LL | match_empty!(0u8); | ^^^ @@ -62,7 +62,7 @@ LL | match_empty!(0u8); = note: the matched value is of type `u8` error[E0004]: non-exhaustive patterns: type `NonEmptyStruct` is non-empty - --> $DIR/match-empty-exhaustive_patterns.rs:91:18 + --> $DIR/empty-match.rs:92:18 | LL | struct NonEmptyStruct(bool); | ---------------------------- `NonEmptyStruct` defined here @@ -74,7 +74,7 @@ LL | match_empty!(NonEmptyStruct(true)); = note: the matched value is of type `NonEmptyStruct` error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty - --> $DIR/match-empty-exhaustive_patterns.rs:93:18 + --> $DIR/empty-match.rs:94:18 | LL | / union NonEmptyUnion1 { LL | | foo: (), @@ -88,7 +88,7 @@ LL | match_empty!((NonEmptyUnion1 { foo: () })); = note: the matched value is of type `NonEmptyUnion1` error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty - --> $DIR/match-empty-exhaustive_patterns.rs:95:18 + --> $DIR/empty-match.rs:96:18 | LL | / union NonEmptyUnion2 { LL | | foo: (), @@ -103,7 +103,7 @@ LL | match_empty!((NonEmptyUnion2 { foo: () })); = note: the matched value is of type `NonEmptyUnion2` error[E0004]: non-exhaustive patterns: `Foo(_)` not covered - --> $DIR/match-empty-exhaustive_patterns.rs:97:18 + --> $DIR/empty-match.rs:98:18 | LL | / enum NonEmptyEnum1 { LL | | Foo(bool), @@ -120,7 +120,7 @@ LL | match_empty!(NonEmptyEnum1::Foo(true)); = note: the matched value is of type `NonEmptyEnum1` error[E0004]: non-exhaustive patterns: `Foo(_)` and `Bar` not covered - --> $DIR/match-empty-exhaustive_patterns.rs:99:18 + --> $DIR/empty-match.rs:100:18 | LL | / enum NonEmptyEnum2 { LL | | Foo(bool), @@ -141,7 +141,7 @@ LL | match_empty!(NonEmptyEnum2::Foo(true)); = note: the matched value is of type `NonEmptyEnum2` error[E0004]: non-exhaustive patterns: `V1`, `V2`, `V3` and 2 more not covered - --> $DIR/match-empty-exhaustive_patterns.rs:101:18 + --> $DIR/empty-match.rs:102:18 | LL | / enum NonEmptyEnum5 { LL | | V1, V2, V3, V4, V5, @@ -155,7 +155,7 @@ LL | match_empty!(NonEmptyEnum5::V1); = note: the matched value is of type `NonEmptyEnum5` error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/match-empty-exhaustive_patterns.rs:104:18 + --> $DIR/empty-match.rs:105:18 | LL | match_false!(0u8); | ^^^ pattern `_` not covered @@ -164,7 +164,7 @@ LL | match_false!(0u8); = note: the matched value is of type `u8` error[E0004]: non-exhaustive patterns: `NonEmptyStruct(_)` not covered - --> $DIR/match-empty-exhaustive_patterns.rs:106:18 + --> $DIR/empty-match.rs:107:18 | LL | struct NonEmptyStruct(bool); | ---------------------------- `NonEmptyStruct` defined here @@ -176,7 +176,7 @@ LL | match_false!(NonEmptyStruct(true)); = note: the matched value is of type `NonEmptyStruct` error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered - --> $DIR/match-empty-exhaustive_patterns.rs:108:18 + --> $DIR/empty-match.rs:109:18 | LL | / union NonEmptyUnion1 { LL | | foo: (), @@ -190,7 +190,7 @@ LL | match_false!((NonEmptyUnion1 { foo: () })); = note: the matched value is of type `NonEmptyUnion1` error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered - --> $DIR/match-empty-exhaustive_patterns.rs:110:18 + --> $DIR/empty-match.rs:111:18 | LL | / union NonEmptyUnion2 { LL | | foo: (), @@ -205,7 +205,7 @@ LL | match_false!((NonEmptyUnion2 { foo: () })); = note: the matched value is of type `NonEmptyUnion2` error[E0004]: non-exhaustive patterns: `Foo(_)` not covered - --> $DIR/match-empty-exhaustive_patterns.rs:112:18 + --> $DIR/empty-match.rs:113:18 | LL | / enum NonEmptyEnum1 { LL | | Foo(bool), @@ -222,7 +222,7 @@ LL | match_false!(NonEmptyEnum1::Foo(true)); = note: the matched value is of type `NonEmptyEnum1` error[E0004]: non-exhaustive patterns: `Foo(_)` and `Bar` not covered - --> $DIR/match-empty-exhaustive_patterns.rs:114:18 + --> $DIR/empty-match.rs:115:18 | LL | / enum NonEmptyEnum2 { LL | | Foo(bool), @@ -243,7 +243,7 @@ LL | match_false!(NonEmptyEnum2::Foo(true)); = note: the matched value is of type `NonEmptyEnum2` error[E0004]: non-exhaustive patterns: `V1`, `V2`, `V3` and 2 more not covered - --> $DIR/match-empty-exhaustive_patterns.rs:116:18 + --> $DIR/empty-match.rs:117:18 | LL | / enum NonEmptyEnum5 { LL | | V1, V2, V3, V4, V5, diff --git a/src/test/ui/pattern/usefulness/match-empty.stderr b/src/test/ui/pattern/usefulness/empty-match.normal.stderr similarity index 91% rename from src/test/ui/pattern/usefulness/match-empty.stderr rename to src/test/ui/pattern/usefulness/empty-match.normal.stderr index 6065c552390..7db11f146b2 100644 --- a/src/test/ui/pattern/usefulness/match-empty.stderr +++ b/src/test/ui/pattern/usefulness/empty-match.normal.stderr @@ -1,47 +1,47 @@ error: unreachable pattern - --> $DIR/match-empty.rs:51:9 + --> $DIR/empty-match.rs:53:9 | LL | _ => {}, | ^ | note: the lint level is defined here - --> $DIR/match-empty.rs:4:9 + --> $DIR/empty-match.rs:6:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/match-empty.rs:54:9 + --> $DIR/empty-match.rs:56:9 | LL | _ if false => {}, | ^ error: unreachable pattern - --> $DIR/match-empty.rs:61:9 + --> $DIR/empty-match.rs:63:9 | LL | _ => {}, | ^ error: unreachable pattern - --> $DIR/match-empty.rs:64:9 + --> $DIR/empty-match.rs:66:9 | LL | _ if false => {}, | ^ error: unreachable pattern - --> $DIR/match-empty.rs:71:9 + --> $DIR/empty-match.rs:73:9 | LL | _ => {}, | ^ error: unreachable pattern - --> $DIR/match-empty.rs:74:9 + --> $DIR/empty-match.rs:76:9 | LL | _ if false => {}, | ^ error[E0004]: non-exhaustive patterns: type `u8` is non-empty - --> $DIR/match-empty.rs:89:18 + --> $DIR/empty-match.rs:90:18 | LL | match_empty!(0u8); | ^^^ @@ -50,7 +50,7 @@ LL | match_empty!(0u8); = note: the matched value is of type `u8` error[E0004]: non-exhaustive patterns: type `NonEmptyStruct` is non-empty - --> $DIR/match-empty.rs:91:18 + --> $DIR/empty-match.rs:92:18 | LL | struct NonEmptyStruct(bool); | ---------------------------- `NonEmptyStruct` defined here @@ -62,7 +62,7 @@ LL | match_empty!(NonEmptyStruct(true)); = note: the matched value is of type `NonEmptyStruct` error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty - --> $DIR/match-empty.rs:93:18 + --> $DIR/empty-match.rs:94:18 | LL | / union NonEmptyUnion1 { LL | | foo: (), @@ -76,7 +76,7 @@ LL | match_empty!((NonEmptyUnion1 { foo: () })); = note: the matched value is of type `NonEmptyUnion1` error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty - --> $DIR/match-empty.rs:95:18 + --> $DIR/empty-match.rs:96:18 | LL | / union NonEmptyUnion2 { LL | | foo: (), @@ -91,7 +91,7 @@ LL | match_empty!((NonEmptyUnion2 { foo: () })); = note: the matched value is of type `NonEmptyUnion2` error[E0004]: non-exhaustive patterns: `Foo(_)` not covered - --> $DIR/match-empty.rs:97:18 + --> $DIR/empty-match.rs:98:18 | LL | / enum NonEmptyEnum1 { LL | | Foo(bool), @@ -108,7 +108,7 @@ LL | match_empty!(NonEmptyEnum1::Foo(true)); = note: the matched value is of type `NonEmptyEnum1` error[E0004]: non-exhaustive patterns: `Foo(_)` and `Bar` not covered - --> $DIR/match-empty.rs:99:18 + --> $DIR/empty-match.rs:100:18 | LL | / enum NonEmptyEnum2 { LL | | Foo(bool), @@ -129,7 +129,7 @@ LL | match_empty!(NonEmptyEnum2::Foo(true)); = note: the matched value is of type `NonEmptyEnum2` error[E0004]: non-exhaustive patterns: `V1`, `V2`, `V3` and 2 more not covered - --> $DIR/match-empty.rs:101:18 + --> $DIR/empty-match.rs:102:18 | LL | / enum NonEmptyEnum5 { LL | | V1, V2, V3, V4, V5, @@ -143,7 +143,7 @@ LL | match_empty!(NonEmptyEnum5::V1); = note: the matched value is of type `NonEmptyEnum5` error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/match-empty.rs:104:18 + --> $DIR/empty-match.rs:105:18 | LL | match_false!(0u8); | ^^^ pattern `_` not covered @@ -152,7 +152,7 @@ LL | match_false!(0u8); = note: the matched value is of type `u8` error[E0004]: non-exhaustive patterns: `NonEmptyStruct(_)` not covered - --> $DIR/match-empty.rs:106:18 + --> $DIR/empty-match.rs:107:18 | LL | struct NonEmptyStruct(bool); | ---------------------------- `NonEmptyStruct` defined here @@ -164,7 +164,7 @@ LL | match_false!(NonEmptyStruct(true)); = note: the matched value is of type `NonEmptyStruct` error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered - --> $DIR/match-empty.rs:108:18 + --> $DIR/empty-match.rs:109:18 | LL | / union NonEmptyUnion1 { LL | | foo: (), @@ -178,7 +178,7 @@ LL | match_false!((NonEmptyUnion1 { foo: () })); = note: the matched value is of type `NonEmptyUnion1` error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered - --> $DIR/match-empty.rs:110:18 + --> $DIR/empty-match.rs:111:18 | LL | / union NonEmptyUnion2 { LL | | foo: (), @@ -193,7 +193,7 @@ LL | match_false!((NonEmptyUnion2 { foo: () })); = note: the matched value is of type `NonEmptyUnion2` error[E0004]: non-exhaustive patterns: `Foo(_)` not covered - --> $DIR/match-empty.rs:112:18 + --> $DIR/empty-match.rs:113:18 | LL | / enum NonEmptyEnum1 { LL | | Foo(bool), @@ -210,7 +210,7 @@ LL | match_false!(NonEmptyEnum1::Foo(true)); = note: the matched value is of type `NonEmptyEnum1` error[E0004]: non-exhaustive patterns: `Foo(_)` and `Bar` not covered - --> $DIR/match-empty.rs:114:18 + --> $DIR/empty-match.rs:115:18 | LL | / enum NonEmptyEnum2 { LL | | Foo(bool), @@ -231,7 +231,7 @@ LL | match_false!(NonEmptyEnum2::Foo(true)); = note: the matched value is of type `NonEmptyEnum2` error[E0004]: non-exhaustive patterns: `V1`, `V2`, `V3` and 2 more not covered - --> $DIR/match-empty.rs:116:18 + --> $DIR/empty-match.rs:117:18 | LL | / enum NonEmptyEnum5 { LL | | V1, V2, V3, V4, V5, diff --git a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs b/src/test/ui/pattern/usefulness/empty-match.rs similarity index 91% rename from src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs rename to src/test/ui/pattern/usefulness/empty-match.rs index c5c3a214f9a..98d8ac18002 100644 --- a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs +++ b/src/test/ui/pattern/usefulness/empty-match.rs @@ -1,7 +1,8 @@ // aux-build:empty.rs +// revisions: normal exhaustive_patterns #![feature(never_type)] #![feature(never_type_fallback)] -#![feature(exhaustive_patterns)] +#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![deny(unreachable_patterns)] extern crate empty; @@ -79,11 +80,11 @@ fn never(x: !) { fn main() { match None:: { None => {} - Some(_) => {} //~ ERROR unreachable pattern + Some(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern } match None:: { None => {} - Some(_) => {} //~ ERROR unreachable pattern + Some(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern } match_empty!(0u8); diff --git a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-deny.rs b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-deny.rs deleted file mode 100644 index 9292f22e09e..00000000000 --- a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-deny.rs +++ /dev/null @@ -1,48 +0,0 @@ -#![feature(exclusive_range_pattern)] - -macro_rules! m { - ($s:expr, $($t:tt)+) => { - match $s { $($t)+ => {} } - } -} - -fn main() { - match 0usize { - //~^ ERROR non-exhaustive patterns - 0 ..= usize::MAX => {} - } - - match 0isize { - //~^ ERROR non-exhaustive patterns - isize::MIN ..= isize::MAX => {} - } - - m!(0usize, 0..=usize::MAX); - //~^ ERROR non-exhaustive patterns - m!(0usize, 0..5 | 5..=usize::MAX); - //~^ ERROR non-exhaustive patterns - m!(0usize, 0..usize::MAX | usize::MAX); - //~^ ERROR non-exhaustive patterns - m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false)); - //~^ ERROR non-exhaustive patterns - - m!(0isize, isize::MIN..=isize::MAX); - //~^ ERROR non-exhaustive patterns - m!(0isize, isize::MIN..5 | 5..=isize::MAX); - //~^ ERROR non-exhaustive patterns - m!(0isize, isize::MIN..isize::MAX | isize::MAX); - //~^ ERROR non-exhaustive patterns - m!((0isize, true), (isize::MIN..5, true) - | (5..=isize::MAX, true) | (isize::MIN..=isize::MAX, false)); - //~^^ ERROR non-exhaustive patterns - - match 0isize { - //~^ ERROR non-exhaustive patterns - isize::MIN ..= -1 => {} - 0 => {} - 1 ..= isize::MAX => {} - } - - match 7usize {} - //~^ ERROR non-exhaustive patterns -} diff --git a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-allow.stderr b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr similarity index 89% rename from src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-allow.stderr rename to src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr index 0b3c65166ee..25632934583 100644 --- a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-allow.stderr +++ b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: type `usize` is non-empty - --> $DIR/pointer-sized-int-allow.rs:36:11 + --> $DIR/pointer-sized-int.rs:48:11 | LL | match 7usize {} | ^^^^^^ diff --git a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-deny.stderr b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr similarity index 92% rename from src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-deny.stderr rename to src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr index 9d566b0e775..e8ac9f3cfe1 100644 --- a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-deny.stderr +++ b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int-deny.rs:10:11 + --> $DIR/pointer-sized-int.rs:12:11 | LL | match 0usize { | ^^^^^^ pattern `_` not covered @@ -10,7 +10,7 @@ LL | match 0usize { = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int-deny.rs:15:11 + --> $DIR/pointer-sized-int.rs:17:11 | LL | match 0isize { | ^^^^^^ pattern `_` not covered @@ -21,7 +21,7 @@ LL | match 0isize { = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int-deny.rs:20:8 + --> $DIR/pointer-sized-int.rs:22:8 | LL | m!(0usize, 0..=usize::MAX); | ^^^^^^ pattern `_` not covered @@ -32,7 +32,7 @@ LL | m!(0usize, 0..=usize::MAX); = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int-deny.rs:22:8 + --> $DIR/pointer-sized-int.rs:24:8 | LL | m!(0usize, 0..5 | 5..=usize::MAX); | ^^^^^^ pattern `_` not covered @@ -43,7 +43,7 @@ LL | m!(0usize, 0..5 | 5..=usize::MAX); = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int-deny.rs:24:8 + --> $DIR/pointer-sized-int.rs:26:8 | LL | m!(0usize, 0..usize::MAX | usize::MAX); | ^^^^^^ pattern `_` not covered @@ -54,7 +54,7 @@ LL | m!(0usize, 0..usize::MAX | usize::MAX); = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching error[E0004]: non-exhaustive patterns: `(_, _)` not covered - --> $DIR/pointer-sized-int-deny.rs:26:8 + --> $DIR/pointer-sized-int.rs:28:8 | LL | m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false)); | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered @@ -63,7 +63,7 @@ LL | m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize:: = note: the matched value is of type `(usize, bool)` error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int-deny.rs:29:8 + --> $DIR/pointer-sized-int.rs:31:8 | LL | m!(0isize, isize::MIN..=isize::MAX); | ^^^^^^ pattern `_` not covered @@ -74,7 +74,7 @@ LL | m!(0isize, isize::MIN..=isize::MAX); = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int-deny.rs:31:8 + --> $DIR/pointer-sized-int.rs:33:8 | LL | m!(0isize, isize::MIN..5 | 5..=isize::MAX); | ^^^^^^ pattern `_` not covered @@ -85,7 +85,7 @@ LL | m!(0isize, isize::MIN..5 | 5..=isize::MAX); = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int-deny.rs:33:8 + --> $DIR/pointer-sized-int.rs:35:8 | LL | m!(0isize, isize::MIN..isize::MAX | isize::MAX); | ^^^^^^ pattern `_` not covered @@ -96,7 +96,7 @@ LL | m!(0isize, isize::MIN..isize::MAX | isize::MAX); = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching error[E0004]: non-exhaustive patterns: `(_, _)` not covered - --> $DIR/pointer-sized-int-deny.rs:35:8 + --> $DIR/pointer-sized-int.rs:37:8 | LL | m!((0isize, true), (isize::MIN..5, true) | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered @@ -105,7 +105,7 @@ LL | m!((0isize, true), (isize::MIN..5, true) = note: the matched value is of type `(isize, bool)` error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int-deny.rs:39:11 + --> $DIR/pointer-sized-int.rs:41:11 | LL | match 0isize { | ^^^^^^ pattern `_` not covered @@ -116,7 +116,7 @@ LL | match 0isize { = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching error[E0004]: non-exhaustive patterns: type `usize` is non-empty - --> $DIR/pointer-sized-int-deny.rs:46:11 + --> $DIR/pointer-sized-int.rs:48:11 | LL | match 7usize {} | ^^^^^^ diff --git a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-allow.rs b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs similarity index 60% rename from src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-allow.rs rename to src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs index 6173053cc4f..1ed18c26763 100644 --- a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-allow.rs +++ b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs @@ -1,5 +1,6 @@ -#![feature(precise_pointer_size_matching)] +// revisions: allow deny #![feature(exclusive_range_pattern)] +#![cfg_attr(allow, feature(precise_pointer_size_matching))] macro_rules! m { ($s:expr, $($t:tt)+) => { @@ -9,25 +10,36 @@ macro_rules! m { fn main() { match 0usize { + //[deny]~^ ERROR non-exhaustive patterns 0 ..= usize::MAX => {} } match 0isize { + //[deny]~^ ERROR non-exhaustive patterns isize::MIN ..= isize::MAX => {} } m!(0usize, 0..=usize::MAX); + //[deny]~^ ERROR non-exhaustive patterns m!(0usize, 0..5 | 5..=usize::MAX); + //[deny]~^ ERROR non-exhaustive patterns m!(0usize, 0..usize::MAX | usize::MAX); + //[deny]~^ ERROR non-exhaustive patterns m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false)); + //[deny]~^ ERROR non-exhaustive patterns m!(0isize, isize::MIN..=isize::MAX); + //[deny]~^ ERROR non-exhaustive patterns m!(0isize, isize::MIN..5 | 5..=isize::MAX); + //[deny]~^ ERROR non-exhaustive patterns m!(0isize, isize::MIN..isize::MAX | isize::MAX); + //[deny]~^ ERROR non-exhaustive patterns m!((0isize, true), (isize::MIN..5, true) | (5..=isize::MAX, true) | (isize::MIN..=isize::MAX, false)); + //[deny]~^^ ERROR non-exhaustive patterns match 0isize { + //[deny]~^ ERROR non-exhaustive patterns isize::MIN ..= -1 => {} 0 => {} 1 ..= isize::MAX => {} diff --git a/src/test/ui/pattern/usefulness/match-empty.rs b/src/test/ui/pattern/usefulness/match-empty.rs deleted file mode 100644 index 10ea2a10406..00000000000 --- a/src/test/ui/pattern/usefulness/match-empty.rs +++ /dev/null @@ -1,118 +0,0 @@ -// aux-build:empty.rs -#![feature(never_type)] -#![feature(never_type_fallback)] -#![deny(unreachable_patterns)] - -extern crate empty; - -enum EmptyEnum {} - -struct NonEmptyStruct(bool); //~ `NonEmptyStruct` defined here -union NonEmptyUnion1 { //~ `NonEmptyUnion1` defined here - foo: (), -} -union NonEmptyUnion2 { //~ `NonEmptyUnion2` defined here - foo: (), - bar: (), -} -enum NonEmptyEnum1 { //~ `NonEmptyEnum1` defined here - Foo(bool), - //~^ not covered - //~| not covered -} -enum NonEmptyEnum2 { //~ `NonEmptyEnum2` defined here - Foo(bool), - //~^ not covered - //~| not covered - Bar, - //~^ not covered - //~| not covered -} -enum NonEmptyEnum5 { //~ `NonEmptyEnum5` defined here - V1, V2, V3, V4, V5, -} - -macro_rules! match_empty { - ($e:expr) => { - match $e {} - }; -} -macro_rules! match_false { - ($e:expr) => { - match $e { - _ if false => {} - } - }; -} - -fn empty_enum(x: EmptyEnum) { - match x {} // ok - match x { - _ => {}, //~ ERROR unreachable pattern - } - match x { - _ if false => {}, //~ ERROR unreachable pattern - } -} - -fn empty_foreign_enum(x: empty::EmptyForeignEnum) { - match x {} // ok - match x { - _ => {}, //~ ERROR unreachable pattern - } - match x { - _ if false => {}, //~ ERROR unreachable pattern - } -} - -fn never(x: !) { - match x {} // ok - match x { - _ => {}, //~ ERROR unreachable pattern - } - match x { - _ if false => {}, //~ ERROR unreachable pattern - } -} - -fn main() { - // `exhaustive_patterns` is not on, so uninhabited branches are not detected as unreachable. - match None:: { - None => {} - Some(_) => {} - } - match None:: { - None => {} - Some(_) => {} - } - - match_empty!(0u8); - //~^ ERROR type `u8` is non-empty - match_empty!(NonEmptyStruct(true)); - //~^ ERROR type `NonEmptyStruct` is non-empty - match_empty!((NonEmptyUnion1 { foo: () })); - //~^ ERROR type `NonEmptyUnion1` is non-empty - match_empty!((NonEmptyUnion2 { foo: () })); - //~^ ERROR type `NonEmptyUnion2` is non-empty - match_empty!(NonEmptyEnum1::Foo(true)); - //~^ ERROR `Foo(_)` not covered - match_empty!(NonEmptyEnum2::Foo(true)); - //~^ ERROR `Foo(_)` and `Bar` not covered - match_empty!(NonEmptyEnum5::V1); - //~^ ERROR `V1`, `V2`, `V3` and 2 more not covered - - match_false!(0u8); - //~^ ERROR `_` not covered - match_false!(NonEmptyStruct(true)); - //~^ ERROR `NonEmptyStruct(_)` not covered - match_false!((NonEmptyUnion1 { foo: () })); - //~^ ERROR `NonEmptyUnion1 { .. }` not covered - match_false!((NonEmptyUnion2 { foo: () })); - //~^ ERROR `NonEmptyUnion2 { .. }` not covered - match_false!(NonEmptyEnum1::Foo(true)); - //~^ ERROR `Foo(_)` not covered - match_false!(NonEmptyEnum2::Foo(true)); - //~^ ERROR `Foo(_)` and `Bar` not covered - match_false!(NonEmptyEnum5::V1); - //~^ ERROR `V1`, `V2`, `V3` and 2 more not covered -}