Skip to content

Commit d4c91b2

Browse files
authored
Merge pull request #1784 from birkenfeld/update
Demote never_loop lint to Allow for now
2 parents e72c70d + 3ba4e8b commit d4c91b2

File tree

134 files changed

+140
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+140
-139
lines changed

README.md

Lines changed: 1 addition & 1 deletion

clippy_lints/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
324324
enum_variants::STUTTER,
325325
if_not_else::IF_NOT_ELSE,
326326
items_after_statements::ITEMS_AFTER_STATEMENTS,
327+
loops::NEVER_LOOP,
327328
matches::SINGLE_MATCH_ELSE,
328329
mem_forget::MEM_FORGET,
329330
methods::FILTER_MAP,
@@ -419,7 +420,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
419420
loops::FOR_LOOP_OVER_RESULT,
420421
loops::ITER_NEXT_LOOP,
421422
loops::NEEDLESS_RANGE_LOOP,
422-
loops::NEVER_LOOP,
423423
loops::REVERSE_RANGE_LOOP,
424424
loops::UNUSED_COLLECT,
425425
loops::WHILE_LET_LOOP,

clippy_lints/src/loops.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,21 +285,24 @@ declare_lint! {
285285
"looping on a map using `iter` when `keys` or `values` would do"
286286
}
287287

288-
/// **What it does:** Checks for loops that contain an unconditional `break`.
288+
/// **What it does:** Checks for loops that contain an unconditional `break`
289+
/// or `return`.
289290
///
290291
/// **Why is this bad?** This loop never loops, all it does is obfuscating the
291292
/// code.
292293
///
293-
/// **Known problems:** None.
294+
/// **Known problems:** Ignores `continue` statements in the loop that create
295+
/// nontrivial control flow. Therefore set to `Allow` by default.
296+
/// See https://github.com/Manishearth/rust-clippy/issues/1586
294297
///
295298
/// **Example:**
296299
/// ```rust
297300
/// loop { ..; break; }
298301
/// ```
299302
declare_lint! {
300303
pub NEVER_LOOP,
301-
Warn,
302-
"any loop with an unconditional `break` statement"
304+
Allow,
305+
"any loop with an unconditional `break` or `return` statement"
303306
}
304307

305308
#[derive(Copy, Clone)]

clippy_lints/src/utils/higher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ pub fn range(expr: &hir::Expr) -> Option<Range> {
7676
end: None,
7777
limits: ast::RangeLimits::HalfOpen,
7878
})
79-
} else if match_path(path, &paths::RANGE_INCLUSIVE_NON_EMPTY_STD) ||
80-
match_path(path, &paths::RANGE_INCLUSIVE_NON_EMPTY) {
79+
} else if match_path(path, &paths::RANGE_INCLUSIVE_STD) ||
80+
match_path(path, &paths::RANGE_INCLUSIVE) {
8181
Some(Range {
8282
start: get_field("start", fields),
8383
end: get_field("end", fields),

clippy_lints/src/utils/paths.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ pub const RANGE_FROM_STD: [&'static str; 3] = ["std", "ops", "RangeFrom"];
4949
pub const RANGE_FULL: [&'static str; 3] = ["core", "ops", "RangeFull"];
5050
pub const RANGE_FULL_STD: [&'static str; 3] = ["std", "ops", "RangeFull"];
5151
pub const RANGE_INCLUSIVE: [&'static str; 3] = ["core", "ops", "RangeInclusive"];
52-
pub const RANGE_INCLUSIVE_NON_EMPTY: [&'static str; 4] = ["core", "ops", "RangeInclusive", "NonEmpty"];
53-
pub const RANGE_INCLUSIVE_NON_EMPTY_STD: [&'static str; 4] = ["std", "ops", "RangeInclusive", "NonEmpty"];
5452
pub const RANGE_INCLUSIVE_STD: [&'static str; 3] = ["std", "ops", "RangeInclusive"];
5553
pub const RANGE_STD: [&'static str; 3] = ["std", "ops", "Range"];
5654
pub const RANGE_TO: [&'static str; 3] = ["core", "ops", "RangeTo"];

clippy_tests/examples/absurd-extreme-comparisons.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ error: <-comparison of unit values detected. This will always be false
159159
|
160160
= note: `-D unit-cmp` implied by `-D warnings`
161161

162-
error: aborting due to 18 previous errors
162+
error: aborting due to previous error(s)
163163

164164
error: Could not compile `clippy_tests`.
165165

clippy_tests/examples/approx_const.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ error: approximate value of `f{32, 64}::consts::SQRT_2` found. Consider using it
150150
|
151151
= note: `-D approx-constant` implied by `-D warnings`
152152

153-
error: aborting due to 19 previous errors
153+
error: aborting due to previous error(s)
154154

155155
error: Could not compile `clippy_tests`.
156156

clippy_tests/examples/arithmetic.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ error: floating-point arithmetic detected
8787
|
8888
= note: `-D float-arithmetic` implied by `-D warnings`
8989

90-
error: aborting due to 11 previous errors
90+
error: aborting due to previous error(s)
9191

9292
error: Could not compile `clippy_tests`.
9393

clippy_tests/examples/array_indexing.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ error: range is out of bounds
150150
|
151151
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
152152

153-
error: aborting due to 19 previous errors
153+
error: aborting due to previous error(s)
154154

155155
error: Could not compile `clippy_tests`.
156156

clippy_tests/examples/assign_ops.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ error: manual implementation of an assign operation
166166
|
167167
= note: `-D assign-op-pattern` implied by `-D warnings`
168168

169-
error: aborting due to 21 previous errors
169+
error: aborting due to previous error(s)
170170

171171
error: Could not compile `clippy_tests`.
172172

0 commit comments

Comments
 (0)