File tree 2 files changed +9
-8
lines changed
2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,8 @@ pub struct Pass;
47
47
impl Pass {
48
48
fn expr_match ( cx : & LateContext < ' _ , ' _ > , expr : & rustc:: hir:: Expr ) {
49
49
match & expr. node {
50
- ExprKind :: Block ( block, ..) => {
50
+ // loops could be using `break` instead of `return`
51
+ ExprKind :: Block ( block, ..) | ExprKind :: Loop ( block, ..) => {
51
52
if let Some ( expr) = & block. expr {
52
53
Self :: expr_match ( cx, expr) ;
53
54
}
@@ -85,12 +86,6 @@ impl Pass {
85
86
Self :: expr_match ( cx, & arm. body ) ;
86
87
}
87
88
} ,
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
- } ,
94
89
// skip if it already has a return statement
95
90
ExprKind :: Ret ( ..) => ( ) ,
96
91
// everything else is missing `return`
Original file line number Diff line number Diff line change @@ -30,6 +30,12 @@ error: missing return statement
30
30
38 | true
31
31
| ^^^^ help: add `return` as shown: `return true`
32
32
33
+ error: missing return statement
34
+ --> $DIR/implicit_return.rs:46:9
35
+ |
36
+ 46 | break true;
37
+ | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
38
+
33
39
error: missing return statement
34
40
--> $DIR/implicit_return.rs:52:9
35
41
|
@@ -42,5 +48,5 @@ error: missing return statement
42
48
54 | let _ = || true;
43
49
| ^^^^ help: add `return` as shown: `return true`
44
50
45
- error: aborting due to 7 previous errors
51
+ error: aborting due to 8 previous errors
46
52
You can’t perform that action at this time.
0 commit comments