From 3ba4e8b3fa23f2138a1019db40f6caff7829c651 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Fri, 26 May 2017 09:20:03 +0200 Subject: [PATCH] Demote the never_loop lint to Allow for now. Also add "known problem" to the description, with link to #1586. --- README.md | 2 +- clippy_lints/src/lib.rs | 2 +- clippy_lints/src/loops.rs | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f96f0f9af48..c5b28812e94 100644 --- a/README.md +++ b/README.md @@ -295,7 +295,7 @@ name [needless_return](https://github.com/Manishearth/rust-clippy/wiki#needless_return) | warn | using a return statement like `return expr;` where an expression would suffice [needless_update](https://github.com/Manishearth/rust-clippy/wiki#needless_update) | warn | using `Foo { ..base }` when there are no missing fields [neg_multiply](https://github.com/Manishearth/rust-clippy/wiki#neg_multiply) | warn | multiplying integers with -1 -[never_loop](https://github.com/Manishearth/rust-clippy/wiki#never_loop) | warn | any loop with an unconditional `break` statement +[never_loop](https://github.com/Manishearth/rust-clippy/wiki#never_loop) | allow | any loop with an unconditional `break` or `return` statement [new_ret_no_self](https://github.com/Manishearth/rust-clippy/wiki#new_ret_no_self) | warn | not returning `Self` in a `new` method [new_without_default](https://github.com/Manishearth/rust-clippy/wiki#new_without_default) | warn | `fn new() -> Self` method without `Default` implementation [new_without_default_derive](https://github.com/Manishearth/rust-clippy/wiki#new_without_default_derive) | warn | `fn new() -> Self` without `#[derive]`able `Default` implementation diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index fb0114f8f68..e212aaeaf7b 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -324,6 +324,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { enum_variants::STUTTER, if_not_else::IF_NOT_ELSE, items_after_statements::ITEMS_AFTER_STATEMENTS, + loops::NEVER_LOOP, matches::SINGLE_MATCH_ELSE, mem_forget::MEM_FORGET, methods::FILTER_MAP, @@ -419,7 +420,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { loops::FOR_LOOP_OVER_RESULT, loops::ITER_NEXT_LOOP, loops::NEEDLESS_RANGE_LOOP, - loops::NEVER_LOOP, loops::REVERSE_RANGE_LOOP, loops::UNUSED_COLLECT, loops::WHILE_LET_LOOP, diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 5e49fb609d1..70e7e99a66d 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -285,12 +285,15 @@ declare_lint! { "looping on a map using `iter` when `keys` or `values` would do" } -/// **What it does:** Checks for loops that contain an unconditional `break`. +/// **What it does:** Checks for loops that contain an unconditional `break` +/// or `return`. /// /// **Why is this bad?** This loop never loops, all it does is obfuscating the /// code. /// -/// **Known problems:** None. +/// **Known problems:** Ignores `continue` statements in the loop that create +/// nontrivial control flow. Therefore set to `Allow` by default. +/// See https://github.com/Manishearth/rust-clippy/issues/1586 /// /// **Example:** /// ```rust @@ -298,8 +301,8 @@ declare_lint! { /// ``` declare_lint! { pub NEVER_LOOP, - Warn, - "any loop with an unconditional `break` statement" + Allow, + "any loop with an unconditional `break` or `return` statement" } #[derive(Copy, Clone)]