|
7 | 7 | // option. This file may not be copied, modified, or distributed
|
8 | 8 | // except according to those terms.
|
9 | 9 |
|
| 10 | +#![warn(clippy::match_same_arms)] |
10 | 11 | use crate::rustc::hir::{intravisit::FnKind, Body, ExprKind, FnDecl};
|
11 | 12 | use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
|
12 | 13 | use crate::rustc::{declare_tool_lint, lint_array};
|
@@ -47,7 +48,8 @@ pub struct Pass;
|
47 | 48 | impl Pass {
|
48 | 49 | fn expr_match(cx: &LateContext<'_, '_>, expr: &rustc::hir::Expr) {
|
49 | 50 | match &expr.node {
|
50 |
| - ExprKind::Block(block, ..) => { |
| 51 | + // loops could be using `break` instead of `return` |
| 52 | + ExprKind::Block(block, ..) | ExprKind::Loop(block, ..) => { |
51 | 53 | if let Some(expr) = &block.expr {
|
52 | 54 | Self::expr_match(cx, expr);
|
53 | 55 | }
|
@@ -85,18 +87,6 @@ impl Pass {
|
85 | 87 | Self::expr_match(cx, &arm.body);
|
86 | 88 | }
|
87 | 89 | },
|
88 |
| - // loops could be using `break` instead of `return` |
89 |
| - ExprKind::Loop(block, ..) => { |
90 |
| - if let Some(expr) = &block.expr { |
91 |
| - Self::expr_match(cx, expr); |
92 |
| - } |
93 |
| - // only needed in the case of `break` with `;` at the end |
94 |
| - else if let Some(stmt) = block.stmts.last() { |
95 |
| - if let rustc::hir::StmtKind::Semi(expr, ..) = &stmt.node { |
96 |
| - Self::expr_match(cx, expr); |
97 |
| - } |
98 |
| - } |
99 |
| - }, |
100 | 90 | // skip if it already has a return statement
|
101 | 91 | ExprKind::Ret(..) => (),
|
102 | 92 | // everything else is missing `return`
|
|
0 commit comments