about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/implicit_return.rs6
-rw-r--r--tests/ui/implicit_return.stderr8
2 files changed, 13 insertions, 1 deletions
diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs
index 664f182c533..d29b508ba37 100644
--- a/clippy_lints/src/implicit_return.rs
+++ b/clippy_lints/src/implicit_return.rs
@@ -90,6 +90,12 @@ impl Pass {
                 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(..) => (),
diff --git a/tests/ui/implicit_return.stderr b/tests/ui/implicit_return.stderr
index bba8d942e27..6f4fe12757a 100644
--- a/tests/ui/implicit_return.stderr
+++ b/tests/ui/implicit_return.stderr
@@ -31,6 +31,12 @@ error: missing return statement
    |             ^^^^ help: add `return` as shown: `return true`
 
 error: missing return statement
+  --> $DIR/implicit_return.rs:46:9
+   |
+46 |         break true;
+   |         ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
+
+error: missing return statement
   --> $DIR/implicit_return.rs:52:9
    |
 52 |         true
@@ -42,5 +48,5 @@ error: missing return statement
 54 |     let _ = || true;
    |                ^^^^ help: add `return` as shown: `return true`
 
-error: aborting due to 7 previous errors
+error: aborting due to 8 previous errors