File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,24 +45,37 @@ declare_clippy_lint! {
4545 "a match statement with a single nontrivial arm (i.e. where the other arm is `_ => {}`) instead of `if let`"
4646}
4747
48- /// **What it does:** Checks for matches with a two arms where an `if let` will
48+ /// **What it does:** Checks for matches with a two arms where an `if let else ` will
4949/// usually suffice.
5050///
5151/// **Why is this bad?** Just readability – `if let` nests less than a `match`.
5252///
5353/// **Known problems:** Personal style preferences may differ.
5454///
5555/// **Example:**
56+ ///
57+ /// Using `match`:
58+ ///
5659/// ```rust
5760/// match x {
5861/// Some(ref foo) => bar(foo),
5962/// _ => bar(other_ref),
6063/// }
6164/// ```
65+ ///
66+ /// Using `if let` with `else`:
67+ ///
68+ /// ```rust
69+ /// if let Some(ref foo) = x {
70+ /// bar(foo);
71+ /// } else {
72+ /// bar(other_ref);
73+ /// }
74+ /// ```
6275declare_clippy_lint ! {
6376 pub SINGLE_MATCH_ELSE ,
6477 pedantic,
65- "a match statement with a two arms where the second arm's pattern is a wildcard instead of `if let` "
78+ "a match statement with a two arms where the second arm's pattern is a placeholder instead of a specific match pattern "
6679}
6780
6881/// **What it does:** Checks for matches where all arms match a reference,
Original file line number Diff line number Diff line change 1414
1515#![ warn( clippy:: all) ]
1616#![ allow( unused, clippy:: redundant_pattern_matching) ]
17- #![ warn( clippy:: single_match_else , clippy :: match_same_arms) ]
17+ #![ warn( clippy:: match_same_arms) ]
1818
19- enum ExprNode {
20- ExprAddrOf ,
21- Butterflies ,
22- Unicorns ,
23- }
24-
25- static NODE : ExprNode = ExprNode :: Unicorns ;
2619
2720fn dummy ( ) {
2821}
2922
30- fn unwrap_addr ( ) -> Option < & ' static ExprNode > {
31- match ExprNode :: Butterflies {
32- ExprNode :: ExprAddrOf => Some ( & NODE ) ,
33- _ => { let x = 5 ; None } ,
34- }
35- }
36-
3723fn ref_pats ( ) {
3824 {
3925 let v = & Some ( 0 ) ;
You can’t perform that action at this time.
0 commit comments