]> git.lizzy.rs Git - rust.git/commitdiff
Demote the never_loop lint to Allow for now.
authorGeorg Brandl <georg@python.org>
Fri, 26 May 2017 07:20:03 +0000 (09:20 +0200)
committerGeorg Brandl <georg@python.org>
Fri, 26 May 2017 16:02:43 +0000 (18:02 +0200)
Also add "known problem" to the description, with link to #1586.

README.md
clippy_lints/src/lib.rs
clippy_lints/src/loops.rs

index f96f0f9af48fddd382a1ddc0ad847697924dc353..c5b28812e944be39110bc259037265b252c4a34f 100644 (file)
--- 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
index fb0114f8f683ae0e1fffac08763de6fac8921c7d..e212aaeaf7b8678c5b3fb3af4116a2ad48132167 100644 (file)
@@ -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,
index 5e49fb609d107882c09b9eb25031c1ae86e49420..70e7e99a66dfb20e3dcdc05f7272cd9f72620072 100644 (file)
     "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
 /// ```
 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)]