]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/src/docs/match_ref_pats.txt
New upstream version 1.66.0+dfsg1
[rustc.git] / src / tools / clippy / src / docs / match_ref_pats.txt
CommitLineData
f2b60f7d
FG
1### What it does
2Checks for matches where all arms match a reference,
3suggesting to remove the reference and deref the matched expression
4instead. It also checks for `if let &foo = bar` blocks.
5
6### Why is this bad?
7It just makes the code less readable. That reference
8destructuring adds nothing to the code.
9
10### Example
11```
12match x {
13 &A(ref y) => foo(y),
14 &B => bar(),
15 _ => frob(&x),
16}
17```
18
19Use instead:
20```
21match *x {
22 A(ref y) => foo(y),
23 B => bar(),
24 _ => frob(x),
25}
26```