about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/implicit_return.rs16
1 files changed, 3 insertions, 13 deletions
diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs
index d29b508ba37..543948e39a7 100644
--- a/clippy_lints/src/implicit_return.rs
+++ b/clippy_lints/src/implicit_return.rs
@@ -7,6 +7,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![warn(clippy::match_same_arms)]
 use crate::rustc::hir::{intravisit::FnKind, Body, ExprKind, FnDecl};
 use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
 use crate::rustc::{declare_tool_lint, lint_array};
@@ -47,7 +48,8 @@ pub struct Pass;
 impl Pass {
     fn expr_match(cx: &LateContext<'_, '_>, expr: &rustc::hir::Expr) {
         match &expr.node {
-            ExprKind::Block(block, ..) => {
+            // loops could be using `break` instead of `return`
+            ExprKind::Block(block, ..) | ExprKind::Loop(block, ..) => {
                 if let Some(expr) = &block.expr {
                     Self::expr_match(cx, expr);
                 }
@@ -85,18 +87,6 @@ impl Pass {
                     Self::expr_match(cx, &arm.body);
                 }
             },
-            // loops could be using `break` instead of `return`
-            ExprKind::Loop(block, ..) => {
-                if let Some(expr) = &block.expr {
-                    Self::expr_match(cx, expr);
-                }
-                // only needed in the case of `break` with `;` at the end
-                else if let Some(stmt) = block.stmts.last() {
-                    if let rustc::hir::StmtKind::Semi(expr, ..) = &stmt.node {
-                        Self::expr_match(cx, expr);
-                    }
-                }
-            },
             // skip if it already has a return statement
             ExprKind::Ret(..) => (),
             // everything else is missing `return`