Skip to content

Commit fd7dda0

Browse files
authored
Merge pull request #1871 from uHOOCCOOHu/never_loop_fix
Fix the bug remaining in #1586.
2 parents f7dd769 + d20c451 commit fd7dda0

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Diff for: clippy_lints/src/loops.rs

+1
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ fn contains_continue_decl(decl: &Decl, dest: &NodeId) -> bool {
466466

467467
fn contains_continue_expr(expr: &Expr, dest: &NodeId) -> bool {
468468
match expr.node {
469+
ExprRet(Some(ref e)) |
469470
ExprBox(ref e) |
470471
ExprUnary(_, ref e) |
471472
ExprCast(ref e, _) |

Diff for: clippy_tests/examples/never_loop.rs

+10
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ fn test10() {
103103
}
104104
}
105105

106+
fn test11<F: FnMut() -> i32>(mut f: F) {
107+
loop {
108+
return match f() {
109+
1 => continue,
110+
_ => (),
111+
}
112+
}
113+
}
114+
106115
fn main() {
107116
test1();
108117
test2();
@@ -114,5 +123,6 @@ fn main() {
114123
test8();
115124
test9();
116125
test10();
126+
test11(|| 0);
117127
}
118128

0 commit comments

Comments
 (0)