From 622bfdb2fdfc3da9ca2959b5e9ae686b1c9ed249 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 2 Dec 2020 20:24:20 +0000 Subject: Deduplicate some tests using revisions --- .../empty-match.exhaustive_patterns.stderr | 261 +++++++++++++++++++++ .../pattern/usefulness/empty-match.normal.stderr | 249 ++++++++++++++++++++ src/test/ui/pattern/usefulness/empty-match.rs | 119 ++++++++++ .../integer-ranges/pointer-sized-int-allow.rs | 38 --- .../integer-ranges/pointer-sized-int-allow.stderr | 12 - .../integer-ranges/pointer-sized-int-deny.rs | 48 ---- .../integer-ranges/pointer-sized-int-deny.stderr | 129 ---------- .../integer-ranges/pointer-sized-int.allow.stderr | 12 + .../integer-ranges/pointer-sized-int.deny.stderr | 129 ++++++++++ .../usefulness/integer-ranges/pointer-sized-int.rs | 50 ++++ .../usefulness/match-empty-exhaustive_patterns.rs | 118 ---------- .../match-empty-exhaustive_patterns.stderr | 261 --------------------- src/test/ui/pattern/usefulness/match-empty.rs | 118 ---------- src/test/ui/pattern/usefulness/match-empty.stderr | 249 -------------------- 14 files changed, 820 insertions(+), 973 deletions(-) create mode 100644 src/test/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr create mode 100644 src/test/ui/pattern/usefulness/empty-match.normal.stderr create mode 100644 src/test/ui/pattern/usefulness/empty-match.rs delete mode 100644 src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-allow.rs delete mode 100644 src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-allow.stderr delete mode 100644 src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-deny.rs delete mode 100644 src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-deny.stderr create mode 100644 src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr create mode 100644 src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr create mode 100644 src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs delete mode 100644 src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs delete mode 100644 src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr delete mode 100644 src/test/ui/pattern/usefulness/match-empty.rs delete mode 100644 src/test/ui/pattern/usefulness/match-empty.stderr (limited to 'src/test/ui/pattern/usefulness') diff --git a/src/test/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr b/src/test/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr new file mode 100644 index 00000000000..a5c8af1f814 --- /dev/null +++ b/src/test/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr @@ -0,0 +1,261 @@ +error: unreachable pattern + --> $DIR/empty-match.rs:53:9 + | +LL | _ => {}, + | ^ + | +note: the lint level is defined here + --> $DIR/empty-match.rs:6:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/empty-match.rs:56:9 + | +LL | _ if false => {}, + | ^ + +error: unreachable pattern + --> $DIR/empty-match.rs:63:9 + | +LL | _ => {}, + | ^ + +error: unreachable pattern + --> $DIR/empty-match.rs:66:9 + | +LL | _ if false => {}, + | ^ + +error: unreachable pattern + --> $DIR/empty-match.rs:73:9 + | +LL | _ => {}, + | ^ + +error: unreachable pattern + --> $DIR/empty-match.rs:76:9 + | +LL | _ if false => {}, + | ^ + +error: unreachable pattern + --> $DIR/empty-match.rs:83:9 + | +LL | Some(_) => {} + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/empty-match.rs:87:9 + | +LL | Some(_) => {} + | ^^^^^^^ + +error[E0004]: non-exhaustive patterns: type `u8` is non-empty + --> $DIR/empty-match.rs:90:18 + | +LL | match_empty!(0u8); + | ^^^ + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `u8` + +error[E0004]: non-exhaustive patterns: type `NonEmptyStruct` is non-empty + --> $DIR/empty-match.rs:92:18 + | +LL | struct NonEmptyStruct(bool); + | ---------------------------- `NonEmptyStruct` defined here +... +LL | match_empty!(NonEmptyStruct(true)); + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyStruct` + +error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty + --> $DIR/empty-match.rs:94:18 + | +LL | / union NonEmptyUnion1 { +LL | | foo: (), +LL | | } + | |_- `NonEmptyUnion1` defined here +... +LL | match_empty!((NonEmptyUnion1 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyUnion1` + +error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty + --> $DIR/empty-match.rs:96:18 + | +LL | / union NonEmptyUnion2 { +LL | | foo: (), +LL | | bar: (), +LL | | } + | |_- `NonEmptyUnion2` defined here +... +LL | match_empty!((NonEmptyUnion2 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyUnion2` + +error[E0004]: non-exhaustive patterns: `Foo(_)` not covered + --> $DIR/empty-match.rs:98:18 + | +LL | / enum NonEmptyEnum1 { +LL | | Foo(bool), + | | --- not covered +LL | | +LL | | +LL | | } + | |_- `NonEmptyEnum1` defined here +... +LL | match_empty!(NonEmptyEnum1::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyEnum1` + +error[E0004]: non-exhaustive patterns: `Foo(_)` and `Bar` not covered + --> $DIR/empty-match.rs:100:18 + | +LL | / enum NonEmptyEnum2 { +LL | | Foo(bool), + | | --- not covered +LL | | +LL | | +LL | | Bar, + | | --- not covered +LL | | +LL | | +LL | | } + | |_- `NonEmptyEnum2` defined here +... +LL | match_empty!(NonEmptyEnum2::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyEnum2` + +error[E0004]: non-exhaustive patterns: `V1`, `V2`, `V3` and 2 more not covered + --> $DIR/empty-match.rs:102:18 + | +LL | / enum NonEmptyEnum5 { +LL | | V1, V2, V3, V4, V5, +LL | | } + | |_- `NonEmptyEnum5` defined here +... +LL | match_empty!(NonEmptyEnum5::V1); + | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyEnum5` + +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/empty-match.rs:105:18 + | +LL | match_false!(0u8); + | ^^^ pattern `_` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `u8` + +error[E0004]: non-exhaustive patterns: `NonEmptyStruct(_)` not covered + --> $DIR/empty-match.rs:107:18 + | +LL | struct NonEmptyStruct(bool); + | ---------------------------- `NonEmptyStruct` defined here +... +LL | match_false!(NonEmptyStruct(true)); + | ^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct(_)` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyStruct` + +error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered + --> $DIR/empty-match.rs:109:18 + | +LL | / union NonEmptyUnion1 { +LL | | foo: (), +LL | | } + | |_- `NonEmptyUnion1` defined here +... +LL | match_false!((NonEmptyUnion1 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyUnion1` + +error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered + --> $DIR/empty-match.rs:111:18 + | +LL | / union NonEmptyUnion2 { +LL | | foo: (), +LL | | bar: (), +LL | | } + | |_- `NonEmptyUnion2` defined here +... +LL | match_false!((NonEmptyUnion2 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyUnion2` + +error[E0004]: non-exhaustive patterns: `Foo(_)` not covered + --> $DIR/empty-match.rs:113:18 + | +LL | / enum NonEmptyEnum1 { +LL | | Foo(bool), + | | --- not covered +LL | | +LL | | +LL | | } + | |_- `NonEmptyEnum1` defined here +... +LL | match_false!(NonEmptyEnum1::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyEnum1` + +error[E0004]: non-exhaustive patterns: `Foo(_)` and `Bar` not covered + --> $DIR/empty-match.rs:115:18 + | +LL | / enum NonEmptyEnum2 { +LL | | Foo(bool), + | | --- not covered +LL | | +LL | | +LL | | Bar, + | | --- not covered +LL | | +LL | | +LL | | } + | |_- `NonEmptyEnum2` defined here +... +LL | match_false!(NonEmptyEnum2::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyEnum2` + +error[E0004]: non-exhaustive patterns: `V1`, `V2`, `V3` and 2 more not covered + --> $DIR/empty-match.rs:117:18 + | +LL | / enum NonEmptyEnum5 { +LL | | V1, V2, V3, V4, V5, +LL | | } + | |_- `NonEmptyEnum5` defined here +... +LL | match_false!(NonEmptyEnum5::V1); + | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyEnum5` + +error: aborting due to 22 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/pattern/usefulness/empty-match.normal.stderr b/src/test/ui/pattern/usefulness/empty-match.normal.stderr new file mode 100644 index 00000000000..7db11f146b2 --- /dev/null +++ b/src/test/ui/pattern/usefulness/empty-match.normal.stderr @@ -0,0 +1,249 @@ +error: unreachable pattern + --> $DIR/empty-match.rs:53:9 + | +LL | _ => {}, + | ^ + | +note: the lint level is defined here + --> $DIR/empty-match.rs:6:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/empty-match.rs:56:9 + | +LL | _ if false => {}, + | ^ + +error: unreachable pattern + --> $DIR/empty-match.rs:63:9 + | +LL | _ => {}, + | ^ + +error: unreachable pattern + --> $DIR/empty-match.rs:66:9 + | +LL | _ if false => {}, + | ^ + +error: unreachable pattern + --> $DIR/empty-match.rs:73:9 + | +LL | _ => {}, + | ^ + +error: unreachable pattern + --> $DIR/empty-match.rs:76:9 + | +LL | _ if false => {}, + | ^ + +error[E0004]: non-exhaustive patterns: type `u8` is non-empty + --> $DIR/empty-match.rs:90:18 + | +LL | match_empty!(0u8); + | ^^^ + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `u8` + +error[E0004]: non-exhaustive patterns: type `NonEmptyStruct` is non-empty + --> $DIR/empty-match.rs:92:18 + | +LL | struct NonEmptyStruct(bool); + | ---------------------------- `NonEmptyStruct` defined here +... +LL | match_empty!(NonEmptyStruct(true)); + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyStruct` + +error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty + --> $DIR/empty-match.rs:94:18 + | +LL | / union NonEmptyUnion1 { +LL | | foo: (), +LL | | } + | |_- `NonEmptyUnion1` defined here +... +LL | match_empty!((NonEmptyUnion1 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyUnion1` + +error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty + --> $DIR/empty-match.rs:96:18 + | +LL | / union NonEmptyUnion2 { +LL | | foo: (), +LL | | bar: (), +LL | | } + | |_- `NonEmptyUnion2` defined here +... +LL | match_empty!((NonEmptyUnion2 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyUnion2` + +error[E0004]: non-exhaustive patterns: `Foo(_)` not covered + --> $DIR/empty-match.rs:98:18 + | +LL | / enum NonEmptyEnum1 { +LL | | Foo(bool), + | | --- not covered +LL | | +LL | | +LL | | } + | |_- `NonEmptyEnum1` defined here +... +LL | match_empty!(NonEmptyEnum1::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyEnum1` + +error[E0004]: non-exhaustive patterns: `Foo(_)` and `Bar` not covered + --> $DIR/empty-match.rs:100:18 + | +LL | / enum NonEmptyEnum2 { +LL | | Foo(bool), + | | --- not covered +LL | | +LL | | +LL | | Bar, + | | --- not covered +LL | | +LL | | +LL | | } + | |_- `NonEmptyEnum2` defined here +... +LL | match_empty!(NonEmptyEnum2::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyEnum2` + +error[E0004]: non-exhaustive patterns: `V1`, `V2`, `V3` and 2 more not covered + --> $DIR/empty-match.rs:102:18 + | +LL | / enum NonEmptyEnum5 { +LL | | V1, V2, V3, V4, V5, +LL | | } + | |_- `NonEmptyEnum5` defined here +... +LL | match_empty!(NonEmptyEnum5::V1); + | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyEnum5` + +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/empty-match.rs:105:18 + | +LL | match_false!(0u8); + | ^^^ pattern `_` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `u8` + +error[E0004]: non-exhaustive patterns: `NonEmptyStruct(_)` not covered + --> $DIR/empty-match.rs:107:18 + | +LL | struct NonEmptyStruct(bool); + | ---------------------------- `NonEmptyStruct` defined here +... +LL | match_false!(NonEmptyStruct(true)); + | ^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct(_)` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyStruct` + +error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered + --> $DIR/empty-match.rs:109:18 + | +LL | / union NonEmptyUnion1 { +LL | | foo: (), +LL | | } + | |_- `NonEmptyUnion1` defined here +... +LL | match_false!((NonEmptyUnion1 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyUnion1` + +error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered + --> $DIR/empty-match.rs:111:18 + | +LL | / union NonEmptyUnion2 { +LL | | foo: (), +LL | | bar: (), +LL | | } + | |_- `NonEmptyUnion2` defined here +... +LL | match_false!((NonEmptyUnion2 { foo: () })); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyUnion2` + +error[E0004]: non-exhaustive patterns: `Foo(_)` not covered + --> $DIR/empty-match.rs:113:18 + | +LL | / enum NonEmptyEnum1 { +LL | | Foo(bool), + | | --- not covered +LL | | +LL | | +LL | | } + | |_- `NonEmptyEnum1` defined here +... +LL | match_false!(NonEmptyEnum1::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyEnum1` + +error[E0004]: non-exhaustive patterns: `Foo(_)` and `Bar` not covered + --> $DIR/empty-match.rs:115:18 + | +LL | / enum NonEmptyEnum2 { +LL | | Foo(bool), + | | --- not covered +LL | | +LL | | +LL | | Bar, + | | --- not covered +LL | | +LL | | +LL | | } + | |_- `NonEmptyEnum2` defined here +... +LL | match_false!(NonEmptyEnum2::Foo(true)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyEnum2` + +error[E0004]: non-exhaustive patterns: `V1`, `V2`, `V3` and 2 more not covered + --> $DIR/empty-match.rs:117:18 + | +LL | / enum NonEmptyEnum5 { +LL | | V1, V2, V3, V4, V5, +LL | | } + | |_- `NonEmptyEnum5` defined here +... +LL | match_false!(NonEmptyEnum5::V1); + | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `NonEmptyEnum5` + +error: aborting due to 20 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/pattern/usefulness/empty-match.rs b/src/test/ui/pattern/usefulness/empty-match.rs new file mode 100644 index 00000000000..98d8ac18002 --- /dev/null +++ b/src/test/ui/pattern/usefulness/empty-match.rs @@ -0,0 +1,119 @@ +// aux-build:empty.rs +// revisions: normal exhaustive_patterns +#![feature(never_type)] +#![feature(never_type_fallback)] +#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] +#![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() { + match None:: { + None => {} + Some(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern + } + match None:: { + None => {} + Some(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern + } + + 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 +} 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-allow.rs deleted file mode 100644 index 6173053cc4f..00000000000 --- a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-allow.rs +++ /dev/null @@ -1,38 +0,0 @@ -#![feature(precise_pointer_size_matching)] -#![feature(exclusive_range_pattern)] - -macro_rules! m { - ($s:expr, $($t:tt)+) => { - match $s { $($t)+ => {} } - } -} - -fn main() { - match 0usize { - 0 ..= usize::MAX => {} - } - - match 0isize { - isize::MIN ..= isize::MAX => {} - } - - m!(0usize, 0..=usize::MAX); - m!(0usize, 0..5 | 5..=usize::MAX); - m!(0usize, 0..usize::MAX | usize::MAX); - m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false)); - - m!(0isize, isize::MIN..=isize::MAX); - m!(0isize, isize::MIN..5 | 5..=isize::MAX); - m!(0isize, isize::MIN..isize::MAX | isize::MAX); - m!((0isize, true), (isize::MIN..5, true) - | (5..=isize::MAX, true) | (isize::MIN..=isize::MAX, false)); - - match 0isize { - 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 deleted file mode 100644 index 0b3c65166ee..00000000000 --- a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-allow.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0004]: non-exhaustive patterns: type `usize` is non-empty - --> $DIR/pointer-sized-int-allow.rs:36:11 - | -LL | match 7usize {} - | ^^^^^^ - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `usize` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0004`. 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-deny.stderr b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-deny.stderr deleted file mode 100644 index 9d566b0e775..00000000000 --- a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int-deny.stderr +++ /dev/null @@ -1,129 +0,0 @@ -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int-deny.rs:10:11 - | -LL | match 0usize { - | ^^^^^^ pattern `_` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `usize` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively - = 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 - | -LL | match 0isize { - | ^^^^^^ pattern `_` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `isize` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively - = 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 - | -LL | m!(0usize, 0..=usize::MAX); - | ^^^^^^ pattern `_` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `usize` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively - = 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 - | -LL | m!(0usize, 0..5 | 5..=usize::MAX); - | ^^^^^^ pattern `_` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `usize` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively - = 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 - | -LL | m!(0usize, 0..usize::MAX | usize::MAX); - | ^^^^^^ pattern `_` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `usize` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively - = 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 - | -LL | m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false)); - | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `(usize, bool)` - -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int-deny.rs:29:8 - | -LL | m!(0isize, isize::MIN..=isize::MAX); - | ^^^^^^ pattern `_` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `isize` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively - = 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 - | -LL | m!(0isize, isize::MIN..5 | 5..=isize::MAX); - | ^^^^^^ pattern `_` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `isize` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively - = 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 - | -LL | m!(0isize, isize::MIN..isize::MAX | isize::MAX); - | ^^^^^^ pattern `_` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `isize` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively - = 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 - | -LL | m!((0isize, true), (isize::MIN..5, true) - | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `(isize, bool)` - -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int-deny.rs:39:11 - | -LL | match 0isize { - | ^^^^^^ pattern `_` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `isize` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively - = 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 - | -LL | match 7usize {} - | ^^^^^^ - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `usize` - -error: aborting due to 12 previous errors - -For more information about this error, try `rustc --explain E0004`. 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 new file mode 100644 index 00000000000..25632934583 --- /dev/null +++ b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr @@ -0,0 +1,12 @@ +error[E0004]: non-exhaustive patterns: type `usize` is non-empty + --> $DIR/pointer-sized-int.rs:48:11 + | +LL | match 7usize {} + | ^^^^^^ + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `usize` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. 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 new file mode 100644 index 00000000000..e8ac9f3cfe1 --- /dev/null +++ b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr @@ -0,0 +1,129 @@ +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/pointer-sized-int.rs:12:11 + | +LL | match 0usize { + | ^^^^^^ pattern `_` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `usize` + = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = 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.rs:17:11 + | +LL | match 0isize { + | ^^^^^^ pattern `_` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `isize` + = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = 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.rs:22:8 + | +LL | m!(0usize, 0..=usize::MAX); + | ^^^^^^ pattern `_` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `usize` + = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = 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.rs:24:8 + | +LL | m!(0usize, 0..5 | 5..=usize::MAX); + | ^^^^^^ pattern `_` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `usize` + = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = 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.rs:26:8 + | +LL | m!(0usize, 0..usize::MAX | usize::MAX); + | ^^^^^^ pattern `_` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `usize` + = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = 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.rs:28:8 + | +LL | m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false)); + | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `(usize, bool)` + +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/pointer-sized-int.rs:31:8 + | +LL | m!(0isize, isize::MIN..=isize::MAX); + | ^^^^^^ pattern `_` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `isize` + = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = 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.rs:33:8 + | +LL | m!(0isize, isize::MIN..5 | 5..=isize::MAX); + | ^^^^^^ pattern `_` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `isize` + = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = 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.rs:35:8 + | +LL | m!(0isize, isize::MIN..isize::MAX | isize::MAX); + | ^^^^^^ pattern `_` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `isize` + = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = 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.rs:37:8 + | +LL | m!((0isize, true), (isize::MIN..5, true) + | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `(isize, bool)` + +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/pointer-sized-int.rs:41:11 + | +LL | match 0isize { + | ^^^^^^ pattern `_` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `isize` + = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = 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.rs:48:11 + | +LL | match 7usize {} + | ^^^^^^ + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `usize` + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs new file mode 100644 index 00000000000..1ed18c26763 --- /dev/null +++ b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs @@ -0,0 +1,50 @@ +// revisions: allow deny +#![feature(exclusive_range_pattern)] +#![cfg_attr(allow, feature(precise_pointer_size_matching))] + +macro_rules! m { + ($s:expr, $($t:tt)+) => { + match $s { $($t)+ => {} } + } +} + +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 => {} + } + + match 7usize {} + //~^ ERROR non-exhaustive patterns +} diff --git a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs b/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs deleted file mode 100644 index c5c3a214f9a..00000000000 --- a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs +++ /dev/null @@ -1,118 +0,0 @@ -// aux-build:empty.rs -#![feature(never_type)] -#![feature(never_type_fallback)] -#![feature(exhaustive_patterns)] -#![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() { - match None:: { - None => {} - Some(_) => {} //~ ERROR unreachable pattern - } - match None:: { - None => {} - Some(_) => {} //~ ERROR unreachable pattern - } - - 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 -} diff --git a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr b/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr deleted file mode 100644 index 9d8b5f38e8c..00000000000 --- a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr +++ /dev/null @@ -1,261 +0,0 @@ -error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:52:9 - | -LL | _ => {}, - | ^ - | -note: the lint level is defined here - --> $DIR/match-empty-exhaustive_patterns.rs:5:9 - | -LL | #![deny(unreachable_patterns)] - | ^^^^^^^^^^^^^^^^^^^^ - -error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:55:9 - | -LL | _ if false => {}, - | ^ - -error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:62:9 - | -LL | _ => {}, - | ^ - -error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:65:9 - | -LL | _ if false => {}, - | ^ - -error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:72:9 - | -LL | _ => {}, - | ^ - -error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:75:9 - | -LL | _ if false => {}, - | ^ - -error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:82:9 - | -LL | Some(_) => {} - | ^^^^^^^ - -error: unreachable pattern - --> $DIR/match-empty-exhaustive_patterns.rs:86:9 - | -LL | Some(_) => {} - | ^^^^^^^ - -error[E0004]: non-exhaustive patterns: type `u8` is non-empty - --> $DIR/match-empty-exhaustive_patterns.rs:89:18 - | -LL | match_empty!(0u8); - | ^^^ - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = 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 - | -LL | struct NonEmptyStruct(bool); - | ---------------------------- `NonEmptyStruct` defined here -... -LL | match_empty!(NonEmptyStruct(true)); - | ^^^^^^^^^^^^^^^^^^^^ - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = 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 - | -LL | / union NonEmptyUnion1 { -LL | | foo: (), -LL | | } - | |_- `NonEmptyUnion1` defined here -... -LL | match_empty!((NonEmptyUnion1 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = 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 - | -LL | / union NonEmptyUnion2 { -LL | | foo: (), -LL | | bar: (), -LL | | } - | |_- `NonEmptyUnion2` defined here -... -LL | match_empty!((NonEmptyUnion2 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyUnion2` - -error[E0004]: non-exhaustive patterns: `Foo(_)` not covered - --> $DIR/match-empty-exhaustive_patterns.rs:97:18 - | -LL | / enum NonEmptyEnum1 { -LL | | Foo(bool), - | | --- not covered -LL | | -LL | | -LL | | } - | |_- `NonEmptyEnum1` defined here -... -LL | match_empty!(NonEmptyEnum1::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = 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 - | -LL | / enum NonEmptyEnum2 { -LL | | Foo(bool), - | | --- not covered -LL | | -LL | | -LL | | Bar, - | | --- not covered -LL | | -LL | | -LL | | } - | |_- `NonEmptyEnum2` defined here -... -LL | match_empty!(NonEmptyEnum2::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = 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 - | -LL | / enum NonEmptyEnum5 { -LL | | V1, V2, V3, V4, V5, -LL | | } - | |_- `NonEmptyEnum5` defined here -... -LL | match_empty!(NonEmptyEnum5::V1); - | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyEnum5` - -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/match-empty-exhaustive_patterns.rs:104:18 - | -LL | match_false!(0u8); - | ^^^ pattern `_` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `u8` - -error[E0004]: non-exhaustive patterns: `NonEmptyStruct(_)` not covered - --> $DIR/match-empty-exhaustive_patterns.rs:106:18 - | -LL | struct NonEmptyStruct(bool); - | ---------------------------- `NonEmptyStruct` defined here -... -LL | match_false!(NonEmptyStruct(true)); - | ^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct(_)` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyStruct` - -error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered - --> $DIR/match-empty-exhaustive_patterns.rs:108:18 - | -LL | / union NonEmptyUnion1 { -LL | | foo: (), -LL | | } - | |_- `NonEmptyUnion1` defined here -... -LL | match_false!((NonEmptyUnion1 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyUnion1` - -error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered - --> $DIR/match-empty-exhaustive_patterns.rs:110:18 - | -LL | / union NonEmptyUnion2 { -LL | | foo: (), -LL | | bar: (), -LL | | } - | |_- `NonEmptyUnion2` defined here -... -LL | match_false!((NonEmptyUnion2 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyUnion2` - -error[E0004]: non-exhaustive patterns: `Foo(_)` not covered - --> $DIR/match-empty-exhaustive_patterns.rs:112:18 - | -LL | / enum NonEmptyEnum1 { -LL | | Foo(bool), - | | --- not covered -LL | | -LL | | -LL | | } - | |_- `NonEmptyEnum1` defined here -... -LL | match_false!(NonEmptyEnum1::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = 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 - | -LL | / enum NonEmptyEnum2 { -LL | | Foo(bool), - | | --- not covered -LL | | -LL | | -LL | | Bar, - | | --- not covered -LL | | -LL | | -LL | | } - | |_- `NonEmptyEnum2` defined here -... -LL | match_false!(NonEmptyEnum2::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = 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 - | -LL | / enum NonEmptyEnum5 { -LL | | V1, V2, V3, V4, V5, -LL | | } - | |_- `NonEmptyEnum5` defined here -... -LL | match_false!(NonEmptyEnum5::V1); - | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyEnum5` - -error: aborting due to 22 previous errors - -For more information about this error, try `rustc --explain E0004`. 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 -} diff --git a/src/test/ui/pattern/usefulness/match-empty.stderr b/src/test/ui/pattern/usefulness/match-empty.stderr deleted file mode 100644 index 6065c552390..00000000000 --- a/src/test/ui/pattern/usefulness/match-empty.stderr +++ /dev/null @@ -1,249 +0,0 @@ -error: unreachable pattern - --> $DIR/match-empty.rs:51:9 - | -LL | _ => {}, - | ^ - | -note: the lint level is defined here - --> $DIR/match-empty.rs:4:9 - | -LL | #![deny(unreachable_patterns)] - | ^^^^^^^^^^^^^^^^^^^^ - -error: unreachable pattern - --> $DIR/match-empty.rs:54:9 - | -LL | _ if false => {}, - | ^ - -error: unreachable pattern - --> $DIR/match-empty.rs:61:9 - | -LL | _ => {}, - | ^ - -error: unreachable pattern - --> $DIR/match-empty.rs:64:9 - | -LL | _ if false => {}, - | ^ - -error: unreachable pattern - --> $DIR/match-empty.rs:71:9 - | -LL | _ => {}, - | ^ - -error: unreachable pattern - --> $DIR/match-empty.rs:74:9 - | -LL | _ if false => {}, - | ^ - -error[E0004]: non-exhaustive patterns: type `u8` is non-empty - --> $DIR/match-empty.rs:89:18 - | -LL | match_empty!(0u8); - | ^^^ - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `u8` - -error[E0004]: non-exhaustive patterns: type `NonEmptyStruct` is non-empty - --> $DIR/match-empty.rs:91:18 - | -LL | struct NonEmptyStruct(bool); - | ---------------------------- `NonEmptyStruct` defined here -... -LL | match_empty!(NonEmptyStruct(true)); - | ^^^^^^^^^^^^^^^^^^^^ - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyStruct` - -error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty - --> $DIR/match-empty.rs:93:18 - | -LL | / union NonEmptyUnion1 { -LL | | foo: (), -LL | | } - | |_- `NonEmptyUnion1` defined here -... -LL | match_empty!((NonEmptyUnion1 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyUnion1` - -error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty - --> $DIR/match-empty.rs:95:18 - | -LL | / union NonEmptyUnion2 { -LL | | foo: (), -LL | | bar: (), -LL | | } - | |_- `NonEmptyUnion2` defined here -... -LL | match_empty!((NonEmptyUnion2 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyUnion2` - -error[E0004]: non-exhaustive patterns: `Foo(_)` not covered - --> $DIR/match-empty.rs:97:18 - | -LL | / enum NonEmptyEnum1 { -LL | | Foo(bool), - | | --- not covered -LL | | -LL | | -LL | | } - | |_- `NonEmptyEnum1` defined here -... -LL | match_empty!(NonEmptyEnum1::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyEnum1` - -error[E0004]: non-exhaustive patterns: `Foo(_)` and `Bar` not covered - --> $DIR/match-empty.rs:99:18 - | -LL | / enum NonEmptyEnum2 { -LL | | Foo(bool), - | | --- not covered -LL | | -LL | | -LL | | Bar, - | | --- not covered -LL | | -LL | | -LL | | } - | |_- `NonEmptyEnum2` defined here -... -LL | match_empty!(NonEmptyEnum2::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = 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 - | -LL | / enum NonEmptyEnum5 { -LL | | V1, V2, V3, V4, V5, -LL | | } - | |_- `NonEmptyEnum5` defined here -... -LL | match_empty!(NonEmptyEnum5::V1); - | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyEnum5` - -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/match-empty.rs:104:18 - | -LL | match_false!(0u8); - | ^^^ pattern `_` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `u8` - -error[E0004]: non-exhaustive patterns: `NonEmptyStruct(_)` not covered - --> $DIR/match-empty.rs:106:18 - | -LL | struct NonEmptyStruct(bool); - | ---------------------------- `NonEmptyStruct` defined here -... -LL | match_false!(NonEmptyStruct(true)); - | ^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct(_)` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyStruct` - -error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered - --> $DIR/match-empty.rs:108:18 - | -LL | / union NonEmptyUnion1 { -LL | | foo: (), -LL | | } - | |_- `NonEmptyUnion1` defined here -... -LL | match_false!((NonEmptyUnion1 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyUnion1` - -error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered - --> $DIR/match-empty.rs:110:18 - | -LL | / union NonEmptyUnion2 { -LL | | foo: (), -LL | | bar: (), -LL | | } - | |_- `NonEmptyUnion2` defined here -... -LL | match_false!((NonEmptyUnion2 { foo: () })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyUnion2` - -error[E0004]: non-exhaustive patterns: `Foo(_)` not covered - --> $DIR/match-empty.rs:112:18 - | -LL | / enum NonEmptyEnum1 { -LL | | Foo(bool), - | | --- not covered -LL | | -LL | | -LL | | } - | |_- `NonEmptyEnum1` defined here -... -LL | match_false!(NonEmptyEnum1::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo(_)` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyEnum1` - -error[E0004]: non-exhaustive patterns: `Foo(_)` and `Bar` not covered - --> $DIR/match-empty.rs:114:18 - | -LL | / enum NonEmptyEnum2 { -LL | | Foo(bool), - | | --- not covered -LL | | -LL | | -LL | | Bar, - | | --- not covered -LL | | -LL | | -LL | | } - | |_- `NonEmptyEnum2` defined here -... -LL | match_false!(NonEmptyEnum2::Foo(true)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo(_)` and `Bar` not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = 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 - | -LL | / enum NonEmptyEnum5 { -LL | | V1, V2, V3, V4, V5, -LL | | } - | |_- `NonEmptyEnum5` defined here -... -LL | match_false!(NonEmptyEnum5::V1); - | ^^^^^^^^^^^^^^^^^ patterns `V1`, `V2`, `V3` and 2 more not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `NonEmptyEnum5` - -error: aborting due to 20 previous errors - -For more information about this error, try `rustc --explain E0004`. -- cgit 1.4.1-3-g733a5