]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/match_same_arms.txt
Rollup merge of #101740 - andrewpollack:add-ignore-fuchsia-ui-tests, r=tmandry
[rust.git] / src / tools / clippy / src / docs / match_same_arms.txt
1 ### What it does
2 Checks for `match` with identical arm bodies.
3
4 ### Why is this bad?
5 This is probably a copy & paste error. If arm bodies
6 are the same on purpose, you can factor them
7 [using `|`](https://doc.rust-lang.org/book/patterns.html#multiple-patterns).
8
9 ### Known problems
10 False positive possible with order dependent `match`
11 (see issue
12 [#860](https://github.com/rust-lang/rust-clippy/issues/860)).
13
14 ### Example
15 ```
16 match foo {
17     Bar => bar(),
18     Quz => quz(),
19     Baz => bar(), // <= oops
20 }
21 ```
22
23 This should probably be
24 ```
25 match foo {
26     Bar => bar(),
27     Quz => quz(),
28     Baz => baz(), // <= fixed
29 }
30 ```
31
32 or if the original code was not a typo:
33 ```
34 match foo {
35     Bar | Baz => bar(), // <= shows the intent better
36     Quz => quz(),
37 }
38 ```