]>
Commit | Line | Data |
---|---|---|
f2b60f7d FG |
1 | ### What it does |
2 | Checks for tuple patterns with a wildcard | |
3 | pattern (`_`) is next to a rest pattern (`..`). | |
4 | ||
5 | _NOTE_: While `_, ..` means there is at least one element left, `..` | |
6 | means there are 0 or more elements left. This can make a difference | |
7 | when refactoring, but shouldn't result in errors in the refactored code, | |
8 | since the wildcard pattern isn't used anyway. | |
9 | ||
10 | ### Why is this bad? | |
11 | The wildcard pattern is unneeded as the rest pattern | |
12 | can match that element as well. | |
13 | ||
14 | ### Example | |
15 | ``` | |
16 | match t { | |
17 | TupleStruct(0, .., _) => (), | |
18 | _ => (), | |
19 | } | |
20 | ``` | |
21 | ||
22 | Use instead: | |
23 | ``` | |
24 | match t { | |
25 | TupleStruct(0, ..) => (), | |
26 | _ => (), | |
27 | } | |
28 | ``` |