Skip to content

Commit b44b29e

Browse files
Add test for warning emitting if match is too complex
1 parent 99edb1b commit b44b29e

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

tests/ui/pattern/too_complex_match.rs

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//@ check-pass
2+
3+
#[derive(Default)]
4+
struct BaseCommand {
5+
field01: bool,
6+
field02: bool,
7+
field03: bool,
8+
field04: bool,
9+
field05: bool,
10+
field06: bool,
11+
field07: bool,
12+
field08: bool,
13+
field09: bool,
14+
field10: bool,
15+
field11: bool,
16+
field12: bool,
17+
field13: bool,
18+
field14: bool,
19+
field15: bool,
20+
field16: bool,
21+
field17: bool,
22+
field18: bool,
23+
field19: bool,
24+
field20: bool,
25+
}
26+
27+
fn request_key(command: BaseCommand) {
28+
match command { //~ WARN: `match` is too complex
29+
BaseCommand { field01: true, .. } => {}
30+
BaseCommand { field02: true, .. } => {}
31+
BaseCommand { field03: true, .. } => {}
32+
BaseCommand { field04: true, .. } => {}
33+
BaseCommand { field05: true, .. } => {}
34+
BaseCommand { field06: true, .. } => {}
35+
BaseCommand { field07: true, .. } => {}
36+
BaseCommand { field08: true, .. } => {}
37+
BaseCommand { field09: true, .. } => {}
38+
BaseCommand { field10: true, .. } => {}
39+
BaseCommand { field11: true, .. } => {}
40+
BaseCommand { field12: true, .. } => {}
41+
BaseCommand { field13: true, .. } => {}
42+
BaseCommand { field14: true, .. } => {}
43+
BaseCommand { field15: true, .. } => {}
44+
BaseCommand { field16: true, .. } => {}
45+
BaseCommand { field17: true, .. } => {}
46+
BaseCommand { field18: true, .. } => {}
47+
BaseCommand { field19: true, .. } => {}
48+
BaseCommand { field20: true, .. } => {}
49+
50+
BaseCommand { field01: false, .. } => {}
51+
BaseCommand { field02: false, .. } => {}
52+
BaseCommand { field03: false, .. } => {}
53+
BaseCommand { field04: false, .. } => {}
54+
BaseCommand { field05: false, .. } => {}
55+
BaseCommand { field06: false, .. } => {}
56+
BaseCommand { field07: false, .. } => {}
57+
BaseCommand { field08: false, .. } => {}
58+
BaseCommand { field09: false, .. } => {}
59+
BaseCommand { field10: false, .. } => {}
60+
BaseCommand { field11: false, .. } => {}
61+
BaseCommand { field12: false, .. } => {}
62+
BaseCommand { field13: false, .. } => {}
63+
BaseCommand { field14: false, .. } => {}
64+
BaseCommand { field15: false, .. } => {}
65+
BaseCommand { field16: false, .. } => {}
66+
BaseCommand { field17: false, .. } => {}
67+
BaseCommand { field18: false, .. } => {}
68+
BaseCommand { field19: false, .. } => {}
69+
BaseCommand { field20: false, .. } => {}
70+
}
71+
}
72+
73+
fn main() {
74+
request_key(BaseCommand::default());
75+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
warning: `match` is too complex
2+
--> $DIR/too_complex_match.rs:28:5
3+
|
4+
LL | / match command {
5+
LL | | BaseCommand { field01: true, .. } => {}
6+
LL | | BaseCommand { field02: true, .. } => {}
7+
LL | | BaseCommand { field03: true, .. } => {}
8+
... |
9+
LL | | BaseCommand { field20: false, .. } => {}
10+
LL | | }
11+
| |_____^
12+
13+
warning: 1 warning emitted
14+

0 commit comments

Comments
 (0)