From 14a1a08b5e64374ae8a48389f92e3662ba12c0c4 Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Wed, 5 Jul 2017 09:55:37 +0800 Subject: [PATCH 1/2] Search `continue` in `return` expr. --- clippy_lints/src/loops.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 5bb75f7c2b15..becb423b5f2e 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -466,6 +466,7 @@ fn contains_continue_decl(decl: &Decl, dest: &NodeId) -> bool { fn contains_continue_expr(expr: &Expr, dest: &NodeId) -> bool { match expr.node { + ExprRet(Some(ref e)) | ExprBox(ref e) | ExprUnary(_, ref e) | ExprCast(ref e, _) | From d20c451c2a7cc5755f3f78ef0931755df203ce28 Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Wed, 5 Jul 2017 09:56:05 +0800 Subject: [PATCH 2/2] Add more test for #1586. --- clippy_tests/examples/never_loop.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/clippy_tests/examples/never_loop.rs b/clippy_tests/examples/never_loop.rs index 981331a1d6bd..50b8d4994149 100644 --- a/clippy_tests/examples/never_loop.rs +++ b/clippy_tests/examples/never_loop.rs @@ -103,6 +103,15 @@ fn test10() { } } +fn test11 i32>(mut f: F) { + loop { + return match f() { + 1 => continue, + _ => (), + } + } +} + fn main() { test1(); test2(); @@ -114,5 +123,6 @@ fn main() { test8(); test9(); test10(); + test11(|| 0); }