Introduce new FixedLenSlice constructor

It is used in the case where a variable-length slice pattern is used to
match on an array of known size. This allows considering only those
entries in the array that are captured by one of the patterns.
As a side-effect, diagnostics improve a bit for those cases.
This commit is contained in:
Nadrieril
2019-11-16 16:05:32 +00:00
parent c00ecfa8d2
commit d93c1b320c
4 changed files with 92 additions and 37 deletions

View File

@@ -1,8 +1,8 @@
error[E0004]: non-exhaustive patterns: `&[_, _, _, _]` not covered
error[E0004]: non-exhaustive patterns: `&[..]` not covered
--> $DIR/match-byte-array-patterns-2.rs:4:11
|
LL | match buf {
| ^^^ pattern `&[_, _, _, _]` not covered
| ^^^ pattern `&[..]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms

View File

@@ -12,11 +12,11 @@ fn main() {
[true, .., true] => {}
}
match s3 {
//~^ ERROR `&[false, _, _]` not covered
//~^ ERROR `&[false, .., _]` not covered
[true, .., true] => {}
}
match s10 {
//~^ ERROR `&[false, _, _, _, _, _, _, _, _, _]` not covered
//~^ ERROR `&[false, .., _]` not covered
[true, .., true] => {}
}
@@ -30,7 +30,7 @@ fn main() {
[.., false] => {}
}
match s3 {
//~^ ERROR `&[false, _, true]` not covered
//~^ ERROR `&[false, .., true]` not covered
[true, ..] => {}
[.., false] => {}
}

View File

@@ -6,19 +6,19 @@ LL | match s2 {
|
= 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-exhaustiveness.rs:14:11
|
LL | match s3 {
| ^^ 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
error[E0004]: non-exhaustive patterns: `&[false, _, _, _, _, _, _, _, _, _]` not covered
error[E0004]: non-exhaustive patterns: `&[false, .., _]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:18:11
|
LL | match s10 {
| ^^^ 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
@@ -30,11 +30,11 @@ LL | match s2 {
|
= 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-exhaustiveness.rs:32:11
|
LL | match s3 {
| ^^ pattern `&[false, _, true]` not covered
| ^^ pattern `&[false, .., true]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms