]> git.lizzy.rs Git - rust.git/blob - tests/ui/closures/2229_closure_analysis/match/issue-88331.rs
Rollup merge of #107248 - erikdesjardins:addrspace, r=oli-obk
[rust.git] / tests / ui / closures / 2229_closure_analysis / match / issue-88331.rs
1 // edition:2021
2
3 #[derive(Copy, Clone, PartialEq, Eq)]
4 pub struct Opcode(pub u8);
5
6 impl Opcode {
7     pub const OP1: Opcode = Opcode(0x1);
8 }
9
10 pub fn example1(msg_type: Opcode) -> impl FnMut(&[u8]) {
11     move |i| match msg_type {
12     //~^ ERROR: non-exhaustive patterns: `Opcode(0_u8)` and `Opcode(2_u8..=u8::MAX)` not covered
13         Opcode::OP1 => unimplemented!(),
14     }
15 }
16
17 #[derive(Copy, Clone, PartialEq, Eq)]
18 pub struct Opcode2(Opcode);
19
20 impl Opcode2 {
21     pub const OP2: Opcode2 = Opcode2(Opcode(0x1));
22 }
23
24
25 pub fn example2(msg_type: Opcode2) -> impl FnMut(&[u8]) {
26
27     move |i| match msg_type {
28     //~^ ERROR: non-exhaustive patterns: `Opcode2(Opcode(0_u8))` and `Opcode2(Opcode(2_u8..=u8::MAX))` not covered
29         Opcode2::OP2=> unimplemented!(),
30     }
31 }
32
33 fn main() {}