diff options
| author | bors <bors@rust-lang.org> | 2021-08-28 15:36:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-08-28 15:36:38 +0000 |
| commit | 42a2a53ec13b0e6e915acd09a2a9a963e5fa3b92 (patch) | |
| tree | a83f42849691e128fc2c728dad5001ddcfdd74b9 /src/test | |
| parent | 84b018341284798fa47f8171f4eb04f18f45cf23 (diff) | |
| parent | c4dba5a64efe340a779d8a1ee8c332140c51180e (diff) | |
| download | rust-42a2a53ec13b0e6e915acd09a2a9a963e5fa3b92.tar.gz rust-42a2a53ec13b0e6e915acd09a2a9a963e5fa3b92.zip | |
Auto merge of #88390 - sexxi-goose:missing-case, r=nikomatsakis
Add missing const edge case We don't "process" const so we need to check for additional cases when the PatKind is a Path. We need to make sure that if there is only one variant that there is no field. If there is one or more field, we will want to borrow the match scrutinee Closes https://github.com/rust-lang/rust/issues/88331 r? `@nikomatsakis`
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/closures/2229_closure_analysis/issue-88331.rs | 33 | ||||
| -rw-r--r-- | src/test/ui/closures/2229_closure_analysis/issue-88331.stderr | 27 |
2 files changed, 60 insertions, 0 deletions
diff --git a/src/test/ui/closures/2229_closure_analysis/issue-88331.rs b/src/test/ui/closures/2229_closure_analysis/issue-88331.rs new file mode 100644 index 00000000000..0a6d71c68ae --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/issue-88331.rs @@ -0,0 +1,33 @@ +// edition:2021 + +#[derive(Copy, Clone, PartialEq, Eq)] +pub struct Opcode(pub u8); + +impl Opcode { + pub const OP1: Opcode = Opcode(0x1); +} + +pub fn example1(msg_type: Opcode) -> impl FnMut(&[u8]) { + move |i| match msg_type { + //~^ ERROR: non-exhaustive patterns: `Opcode(0_u8)` and `Opcode(2_u8..=u8::MAX)` not covered + Opcode::OP1 => unimplemented!(), + } +} + +#[derive(Copy, Clone, PartialEq, Eq)] +pub struct Opcode2(Opcode); + +impl Opcode2 { + pub const OP2: Opcode2 = Opcode2(Opcode(0x1)); +} + + +pub fn example2(msg_type: Opcode2) -> impl FnMut(&[u8]) { + + move |i| match msg_type { + //~^ ERROR: non-exhaustive patterns: `Opcode2(Opcode(0_u8))` and `Opcode2(Opcode(2_u8..=u8::MAX))` not covered + Opcode2::OP2=> unimplemented!(), + } +} + +fn main() {} diff --git a/src/test/ui/closures/2229_closure_analysis/issue-88331.stderr b/src/test/ui/closures/2229_closure_analysis/issue-88331.stderr new file mode 100644 index 00000000000..f02d23464f1 --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/issue-88331.stderr @@ -0,0 +1,27 @@ +error[E0004]: non-exhaustive patterns: `Opcode(0_u8)` and `Opcode(2_u8..=u8::MAX)` not covered + --> $DIR/issue-88331.rs:11:20 + | +LL | pub struct Opcode(pub u8); + | -------------------------- `Opcode` defined here +... +LL | move |i| match msg_type { + | ^^^^^^^^ patterns `Opcode(0_u8)` and `Opcode(2_u8..=u8::MAX)` 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 `Opcode` + +error[E0004]: non-exhaustive patterns: `Opcode2(Opcode(0_u8))` and `Opcode2(Opcode(2_u8..=u8::MAX))` not covered + --> $DIR/issue-88331.rs:27:20 + | +LL | pub struct Opcode2(Opcode); + | --------------------------- `Opcode2` defined here +... +LL | move |i| match msg_type { + | ^^^^^^^^ patterns `Opcode2(Opcode(0_u8))` and `Opcode2(Opcode(2_u8..=u8::MAX))` 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 `Opcode2` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0004`. |
