]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_lints/src/formatting.rs
Merge commit '2ca58e7dda4a9eb142599638c59dc04d15961175' into clippyup
[rust.git] / src / tools / clippy / clippy_lints / src / formatting.rs
index eb4b7a826f2ce10d8a05c9f2259f5098af96ce96..1bd16e6cce53a3a5fae6dab1fb18b936c1679682 100644 (file)
 impl EarlyLintPass for Formatting {
     fn check_block(&mut self, cx: &EarlyContext<'_>, block: &Block) {
         for w in block.stmts.windows(2) {
-            match (&w[0].kind, &w[1].kind) {
-                (&StmtKind::Expr(ref first), &StmtKind::Expr(ref second))
-                | (&StmtKind::Expr(ref first), &StmtKind::Semi(ref second)) => {
-                    check_missing_else(cx, first, second);
-                },
-                _ => (),
+            if let (StmtKind::Expr(first), StmtKind::Expr(second) | StmtKind::Semi(second)) = (&w[0].kind, &w[1].kind) {
+                check_missing_else(cx, first, second);
             }
         }
     }
@@ -309,18 +305,10 @@ fn check_missing_else(cx: &EarlyContext<'_>, first: &Expr, second: &Expr) {
 }
 
 fn is_block(expr: &Expr) -> bool {
-    if let ExprKind::Block(..) = expr.kind {
-        true
-    } else {
-        false
-    }
+    matches!(expr.kind, ExprKind::Block(..))
 }
 
 /// Check if the expression is an `if` or `if let`
 fn is_if(expr: &Expr) -> bool {
-    if let ExprKind::If(..) = expr.kind {
-        true
-    } else {
-        false
-    }
+    matches!(expr.kind, ExprKind::If(..))
 }