-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #79072 - oli-obk:byte_str_pat, r=estebank
Fix exhaustiveness in case a byte string literal is used at slice type fixes #79048
- Loading branch information
Showing
7 changed files
with
113 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#[deny(unreachable_patterns)] | ||
|
||
fn parse_data1(data: &[u8]) -> u32 { | ||
match data { | ||
b"" => 1, | ||
_ => 2, | ||
} | ||
} | ||
|
||
fn parse_data2(data: &[u8]) -> u32 { | ||
match data { //~ ERROR non-exhaustive patterns: `&[_, ..]` not covered | ||
b"" => 1, | ||
} | ||
} | ||
|
||
fn parse_data3(data: &[u8; 0]) -> u8 { | ||
match data { | ||
b"" => 1, | ||
} | ||
} | ||
|
||
fn parse_data4(data: &[u8]) -> u8 { | ||
match data { //~ ERROR non-exhaustive patterns | ||
b"aaa" => 0, | ||
[_, _, _] => 1, | ||
} | ||
} | ||
|
||
fn parse_data5(data: &[u8; 3]) -> u8 { | ||
match data { | ||
b"aaa" => 0, | ||
[_, _, _] => 1, | ||
} | ||
} | ||
|
||
fn main() {} |
21 changes: 21 additions & 0 deletions
21
src/test/ui/match/type_polymorphic_byte_str_literals.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered | ||
--> $DIR/type_polymorphic_byte_str_literals.rs:11:11 | ||
| | ||
LL | match data { | ||
| ^^^^ 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: `&[]`, `&[_]`, `&[_, _]` and 1 more not covered | ||
--> $DIR/type_polymorphic_byte_str_literals.rs:23:11 | ||
| | ||
LL | match data { | ||
| ^^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 1 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 `&[u8]` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0004`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters