]> git.lizzy.rs Git - rust.git/commitdiff
Move more into if_let_chain
authorBood Qian <bood@glowing.com>
Sat, 11 Feb 2017 14:11:19 +0000 (22:11 +0800)
committerBood Qian <bood@glowing.com>
Sat, 11 Feb 2017 14:11:19 +0000 (22:11 +0800)
clippy_lints/src/matches.rs

index 310e9a2275337bf6b73074a77392e14fbdde7a83..02d089e1af4388f935bfd3cab52b815550a34aa4 100644 (file)
@@ -353,21 +353,21 @@ fn check_wild_err_arm(cx: &LateContext, ex: &Expr, arms: &[Arm]) {
         for arm in arms {
             if let PatKind::TupleStruct(ref path, ref inner, _) = arm.pats[0].node {
                 let path_str = print::to_string(print::NO_ANN, |s| s.print_qpath(path, false));
-                if inner.iter().any(|pat| pat.node == PatKind::Wild) && path_str == "Err" {
-                    // `Err(_)` arm found
-                    if_let_chain! {[
-                            let ExprBlock(ref block) = arm.body.node,
-                            is_panic_block(cx, block)
-                        ], {
-                            span_note_and_lint(cx,
-                                               MATCH_WILD_ERR_ARM,
-                                               arm.pats[0].span,
-                                               "Err(_) will match all errors, maybe not a good idea",
-                                               arm.pats[0].span,
-                                               "to remove this warning, match each error seperately \
-                                                or use unreachable macro");
-                        }}
-                }
+                if_let_chain! {[
+                    path_str == "Err",
+                    inner.iter().any(|pat| pat.node == PatKind::Wild),
+                    let ExprBlock(ref block) = arm.body.node,
+                    is_panic_block(cx, block)
+                ], {
+                    // `Err(_)` arm with `panic!` found
+                    span_note_and_lint(cx,
+                                       MATCH_WILD_ERR_ARM,
+                                       arm.pats[0].span,
+                                       "Err(_) will match all errors, maybe not a good idea",
+                                       arm.pats[0].span,
+                                       "to remove this warning, match each error seperately \
+                                        or use unreachable macro");
+                }}
             }
         }
     }