Split slice-patterns test as suggested by Centril
This commit is contained in:
parent
7514c48917
commit
098974dadd
5 changed files with 109 additions and 89 deletions
|
@ -1,27 +1,11 @@
|
||||||
#![feature(slice_patterns)]
|
#![feature(slice_patterns)]
|
||||||
#![deny(unreachable_patterns)]
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let s: &[bool] = &[true; 0];
|
let s: &[bool] = &[true; 0];
|
||||||
let s0: &[bool; 0] = &[];
|
|
||||||
let s1: &[bool; 1] = &[false; 1];
|
let s1: &[bool; 1] = &[false; 1];
|
||||||
let s2: &[bool; 2] = &[false; 2];
|
let s2: &[bool; 2] = &[false; 2];
|
||||||
let s3: &[bool; 3] = &[false; 3];
|
let s3: &[bool; 3] = &[false; 3];
|
||||||
|
|
||||||
let [] = s0;
|
|
||||||
let [_] = s1;
|
|
||||||
let [_, _] = s2;
|
|
||||||
|
|
||||||
let [..] = s;
|
|
||||||
let [..] = s0;
|
|
||||||
let [..] = s1;
|
|
||||||
let [..] = s2;
|
|
||||||
let [..] = s3;
|
|
||||||
|
|
||||||
let [_, _, ..] = s2;
|
|
||||||
let [_, .., _] = s2;
|
|
||||||
let [.., _, _] = s2;
|
|
||||||
|
|
||||||
match s1 {
|
match s1 {
|
||||||
[true, ..] => {}
|
[true, ..] => {}
|
||||||
[.., false] => {}
|
[.., false] => {}
|
||||||
|
@ -74,25 +58,6 @@ fn main() {
|
||||||
[.., true] => {}
|
[.., true] => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
match s {
|
|
||||||
[true, ..] => {}
|
|
||||||
[true, ..] => {} //~ ERROR unreachable pattern
|
|
||||||
[true] => {} //~ ERROR unreachable pattern
|
|
||||||
[..] => {}
|
|
||||||
}
|
|
||||||
match s {
|
|
||||||
[.., true] => {}
|
|
||||||
[.., true] => {} //~ ERROR unreachable pattern
|
|
||||||
[true] => {} //~ ERROR unreachable pattern
|
|
||||||
[..] => {}
|
|
||||||
}
|
|
||||||
match s {
|
|
||||||
[false, .., true] => {}
|
|
||||||
[false, .., true] => {} //~ ERROR unreachable pattern
|
|
||||||
[false, true] => {} //~ ERROR unreachable pattern
|
|
||||||
[false] => {}
|
|
||||||
[..] => {}
|
|
||||||
}
|
|
||||||
match s {
|
match s {
|
||||||
//~^ ERROR `&[_, _, .., true]` not covered
|
//~^ ERROR `&[_, _, .., true]` not covered
|
||||||
[] => {}
|
[] => {}
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0004]: non-exhaustive patterns: `&[false, true]` not covered
|
error[E0004]: non-exhaustive patterns: `&[false, true]` not covered
|
||||||
--> $DIR/slice-patterns.rs:29:11
|
--> $DIR/slice-patterns-exhaustiveness.rs:13:11
|
||||||
|
|
|
|
||||||
LL | match s2 {
|
LL | match s2 {
|
||||||
| ^^ pattern `&[false, true]` not covered
|
| ^^ pattern `&[false, true]` not covered
|
||||||
|
@ -7,7 +7,7 @@ LL | match s2 {
|
||||||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||||
|
|
||||||
error[E0004]: non-exhaustive patterns: `&[false, _, true]` not covered
|
error[E0004]: non-exhaustive patterns: `&[false, _, true]` not covered
|
||||||
--> $DIR/slice-patterns.rs:34:11
|
--> $DIR/slice-patterns-exhaustiveness.rs:18:11
|
||||||
|
|
|
|
||||||
LL | match s3 {
|
LL | match s3 {
|
||||||
| ^^ pattern `&[false, _, true]` not covered
|
| ^^ pattern `&[false, _, true]` not covered
|
||||||
|
@ -15,7 +15,7 @@ LL | match s3 {
|
||||||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||||
|
|
||||||
error[E0004]: non-exhaustive patterns: `&[false, .., true]` not covered
|
error[E0004]: non-exhaustive patterns: `&[false, .., true]` not covered
|
||||||
--> $DIR/slice-patterns.rs:39:11
|
--> $DIR/slice-patterns-exhaustiveness.rs:23:11
|
||||||
|
|
|
|
||||||
LL | match s {
|
LL | match s {
|
||||||
| ^ pattern `&[false, .., true]` not covered
|
| ^ pattern `&[false, .., true]` not covered
|
||||||
|
@ -23,7 +23,7 @@ LL | match s {
|
||||||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||||
|
|
||||||
error[E0004]: non-exhaustive patterns: `&[false, _, _]` not covered
|
error[E0004]: non-exhaustive patterns: `&[false, _, _]` not covered
|
||||||
--> $DIR/slice-patterns.rs:46:11
|
--> $DIR/slice-patterns-exhaustiveness.rs:30:11
|
||||||
|
|
|
|
||||||
LL | match s3 {
|
LL | match s3 {
|
||||||
| ^^ pattern `&[false, _, _]` not covered
|
| ^^ pattern `&[false, _, _]` not covered
|
||||||
|
@ -31,7 +31,7 @@ LL | match s3 {
|
||||||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||||
|
|
||||||
error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered
|
error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered
|
||||||
--> $DIR/slice-patterns.rs:50:11
|
--> $DIR/slice-patterns-exhaustiveness.rs:34:11
|
||||||
|
|
|
|
||||||
LL | match s {
|
LL | match s {
|
||||||
| ^ pattern `&[_, ..]` not covered
|
| ^ pattern `&[_, ..]` not covered
|
||||||
|
@ -39,7 +39,7 @@ LL | match s {
|
||||||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||||
|
|
||||||
error[E0004]: non-exhaustive patterns: `&[_, _, ..]` not covered
|
error[E0004]: non-exhaustive patterns: `&[_, _, ..]` not covered
|
||||||
--> $DIR/slice-patterns.rs:54:11
|
--> $DIR/slice-patterns-exhaustiveness.rs:38:11
|
||||||
|
|
|
|
||||||
LL | match s {
|
LL | match s {
|
||||||
| ^ pattern `&[_, _, ..]` not covered
|
| ^ pattern `&[_, _, ..]` not covered
|
||||||
|
@ -47,7 +47,7 @@ LL | match s {
|
||||||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||||
|
|
||||||
error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered
|
error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered
|
||||||
--> $DIR/slice-patterns.rs:59:11
|
--> $DIR/slice-patterns-exhaustiveness.rs:43:11
|
||||||
|
|
|
|
||||||
LL | match s {
|
LL | match s {
|
||||||
| ^ pattern `&[false, ..]` not covered
|
| ^ pattern `&[false, ..]` not covered
|
||||||
|
@ -55,7 +55,7 @@ LL | match s {
|
||||||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||||
|
|
||||||
error[E0004]: non-exhaustive patterns: `&[false, _, ..]` not covered
|
error[E0004]: non-exhaustive patterns: `&[false, _, ..]` not covered
|
||||||
--> $DIR/slice-patterns.rs:64:11
|
--> $DIR/slice-patterns-exhaustiveness.rs:48:11
|
||||||
|
|
|
|
||||||
LL | match s {
|
LL | match s {
|
||||||
| ^ pattern `&[false, _, ..]` not covered
|
| ^ pattern `&[false, _, ..]` not covered
|
||||||
|
@ -63,57 +63,15 @@ LL | match s {
|
||||||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||||
|
|
||||||
error[E0004]: non-exhaustive patterns: `&[_, .., false]` not covered
|
error[E0004]: non-exhaustive patterns: `&[_, .., false]` not covered
|
||||||
--> $DIR/slice-patterns.rs:70:11
|
--> $DIR/slice-patterns-exhaustiveness.rs:54:11
|
||||||
|
|
|
|
||||||
LL | match s {
|
LL | match s {
|
||||||
| ^ pattern `&[_, .., false]` not covered
|
| ^ pattern `&[_, .., false]` not covered
|
||||||
|
|
|
|
||||||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||||
|
|
||||||
error: unreachable pattern
|
|
||||||
--> $DIR/slice-patterns.rs:79:9
|
|
||||||
|
|
|
||||||
LL | [true, ..] => {}
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: lint level defined here
|
|
||||||
--> $DIR/slice-patterns.rs:2:9
|
|
||||||
|
|
|
||||||
LL | #![deny(unreachable_patterns)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: unreachable pattern
|
|
||||||
--> $DIR/slice-patterns.rs:80:9
|
|
||||||
|
|
|
||||||
LL | [true] => {}
|
|
||||||
| ^^^^^^
|
|
||||||
|
|
||||||
error: unreachable pattern
|
|
||||||
--> $DIR/slice-patterns.rs:85:9
|
|
||||||
|
|
|
||||||
LL | [.., true] => {}
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
|
|
||||||
error: unreachable pattern
|
|
||||||
--> $DIR/slice-patterns.rs:86:9
|
|
||||||
|
|
|
||||||
LL | [true] => {}
|
|
||||||
| ^^^^^^
|
|
||||||
|
|
||||||
error: unreachable pattern
|
|
||||||
--> $DIR/slice-patterns.rs:91:9
|
|
||||||
|
|
|
||||||
LL | [false, .., true] => {}
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: unreachable pattern
|
|
||||||
--> $DIR/slice-patterns.rs:92:9
|
|
||||||
|
|
|
||||||
LL | [false, true] => {}
|
|
||||||
| ^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error[E0004]: non-exhaustive patterns: `&[_, _, .., true]` not covered
|
error[E0004]: non-exhaustive patterns: `&[_, _, .., true]` not covered
|
||||||
--> $DIR/slice-patterns.rs:96:11
|
--> $DIR/slice-patterns-exhaustiveness.rs:61:11
|
||||||
|
|
|
|
||||||
LL | match s {
|
LL | match s {
|
||||||
| ^ pattern `&[_, _, .., true]` not covered
|
| ^ pattern `&[_, _, .., true]` not covered
|
||||||
|
@ -121,13 +79,13 @@ LL | match s {
|
||||||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||||
|
|
||||||
error[E0004]: non-exhaustive patterns: `&[true, _, .., _]` not covered
|
error[E0004]: non-exhaustive patterns: `&[true, _, .., _]` not covered
|
||||||
--> $DIR/slice-patterns.rs:103:11
|
--> $DIR/slice-patterns-exhaustiveness.rs:68:11
|
||||||
|
|
|
|
||||||
LL | match s {
|
LL | match s {
|
||||||
| ^ pattern `&[true, _, .., _]` not covered
|
| ^ pattern `&[true, _, .., _]` not covered
|
||||||
|
|
|
|
||||||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||||
|
|
||||||
error: aborting due to 17 previous errors
|
error: aborting due to 11 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0004`.
|
For more information about this error, try `rustc --explain E0004`.
|
27
src/test/ui/pattern/usefulness/slice-patterns-irrefutable.rs
Normal file
27
src/test/ui/pattern/usefulness/slice-patterns-irrefutable.rs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// check-pass
|
||||||
|
#![feature(slice_patterns)]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let s: &[bool] = &[true; 0];
|
||||||
|
let s0: &[bool; 0] = &[];
|
||||||
|
let s1: &[bool; 1] = &[false; 1];
|
||||||
|
let s2: &[bool; 2] = &[false; 2];
|
||||||
|
|
||||||
|
let [] = s0;
|
||||||
|
let [_] = s1;
|
||||||
|
let [_, _] = s2;
|
||||||
|
|
||||||
|
let [..] = s;
|
||||||
|
let [..] = s0;
|
||||||
|
let [..] = s1;
|
||||||
|
let [..] = s2;
|
||||||
|
|
||||||
|
let [_, ..] = s1;
|
||||||
|
let [.., _] = s1;
|
||||||
|
let [_, ..] = s2;
|
||||||
|
let [.., _] = s2;
|
||||||
|
|
||||||
|
let [_, _, ..] = s2;
|
||||||
|
let [_, .., _] = s2;
|
||||||
|
let [.., _, _] = s2;
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
#![feature(slice_patterns)]
|
||||||
|
#![deny(unreachable_patterns)]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let s: &[bool] = &[true; 0];
|
||||||
|
|
||||||
|
match s {
|
||||||
|
[true, ..] => {}
|
||||||
|
[true, ..] => {} //~ ERROR unreachable pattern
|
||||||
|
[true] => {} //~ ERROR unreachable pattern
|
||||||
|
[..] => {}
|
||||||
|
}
|
||||||
|
match s {
|
||||||
|
[.., true] => {}
|
||||||
|
[.., true] => {} //~ ERROR unreachable pattern
|
||||||
|
[true] => {} //~ ERROR unreachable pattern
|
||||||
|
[..] => {}
|
||||||
|
}
|
||||||
|
match s {
|
||||||
|
[false, .., true] => {}
|
||||||
|
[false, .., true] => {} //~ ERROR unreachable pattern
|
||||||
|
[false, true] => {} //~ ERROR unreachable pattern
|
||||||
|
[false] => {}
|
||||||
|
[..] => {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
error: unreachable pattern
|
||||||
|
--> $DIR/slice-patterns-reachability.rs:9:9
|
||||||
|
|
|
||||||
|
LL | [true, ..] => {}
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: lint level defined here
|
||||||
|
--> $DIR/slice-patterns-reachability.rs:2:9
|
||||||
|
|
|
||||||
|
LL | #![deny(unreachable_patterns)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: unreachable pattern
|
||||||
|
--> $DIR/slice-patterns-reachability.rs:10:9
|
||||||
|
|
|
||||||
|
LL | [true] => {}
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
error: unreachable pattern
|
||||||
|
--> $DIR/slice-patterns-reachability.rs:15:9
|
||||||
|
|
|
||||||
|
LL | [.., true] => {}
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
|
error: unreachable pattern
|
||||||
|
--> $DIR/slice-patterns-reachability.rs:16:9
|
||||||
|
|
|
||||||
|
LL | [true] => {}
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
error: unreachable pattern
|
||||||
|
--> $DIR/slice-patterns-reachability.rs:21:9
|
||||||
|
|
|
||||||
|
LL | [false, .., true] => {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: unreachable pattern
|
||||||
|
--> $DIR/slice-patterns-reachability.rs:22:9
|
||||||
|
|
|
||||||
|
LL | [false, true] => {}
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 6 previous errors
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue