Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 7 additions & 4 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,21 +285,24 @@ 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
/// loop { ..; break; }
/// ```
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)]
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/utils/higher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ pub fn range(expr: &hir::Expr) -> Option<Range> {
end: None,
limits: ast::RangeLimits::HalfOpen,
})
} else if match_path(path, &paths::RANGE_INCLUSIVE_NON_EMPTY_STD) ||
match_path(path, &paths::RANGE_INCLUSIVE_NON_EMPTY) {
} else if match_path(path, &paths::RANGE_INCLUSIVE_STD) ||
match_path(path, &paths::RANGE_INCLUSIVE) {
Some(Range {
start: get_field("start", fields),
end: get_field("end", fields),
Expand Down
2 changes: 0 additions & 2 deletions clippy_lints/src/utils/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ pub const RANGE_FROM_STD: [&'static str; 3] = ["std", "ops", "RangeFrom"];
pub const RANGE_FULL: [&'static str; 3] = ["core", "ops", "RangeFull"];
pub const RANGE_FULL_STD: [&'static str; 3] = ["std", "ops", "RangeFull"];
pub const RANGE_INCLUSIVE: [&'static str; 3] = ["core", "ops", "RangeInclusive"];
pub const RANGE_INCLUSIVE_NON_EMPTY: [&'static str; 4] = ["core", "ops", "RangeInclusive", "NonEmpty"];
pub const RANGE_INCLUSIVE_NON_EMPTY_STD: [&'static str; 4] = ["std", "ops", "RangeInclusive", "NonEmpty"];
pub const RANGE_INCLUSIVE_STD: [&'static str; 3] = ["std", "ops", "RangeInclusive"];
pub const RANGE_STD: [&'static str; 3] = ["std", "ops", "Range"];
pub const RANGE_TO: [&'static str; 3] = ["core", "ops", "RangeTo"];
Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/absurd-extreme-comparisons.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ error: <-comparison of unit values detected. This will always be false
|
= note: `-D unit-cmp` implied by `-D warnings`

error: aborting due to 18 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/approx_const.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ error: approximate value of `f{32, 64}::consts::SQRT_2` found. Consider using it
|
= note: `-D approx-constant` implied by `-D warnings`

error: aborting due to 19 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/arithmetic.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ error: floating-point arithmetic detected
|
= note: `-D float-arithmetic` implied by `-D warnings`

error: aborting due to 11 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/array_indexing.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ error: range is out of bounds
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`

error: aborting due to 19 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/assign_ops.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ error: manual implementation of an assign operation
|
= note: `-D assign-op-pattern` implied by `-D warnings`

error: aborting due to 21 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/assign_ops2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ error: variable appears on both sides of an assignment operation
|
= note: `-D misrefactored-assign-op` implied by `-D warnings`

error: aborting due to 8 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/attrs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ error: the since field must contain a semver-compliant version
|
= note: `-D deprecated-semver` implied by `-D warnings`

error: aborting due to 3 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/bit_masks.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ error: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared
|
= note: `-D ineffective-bit-mask` implied by `-D warnings`

error: aborting due to 15 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/blacklisted_name.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ error: use of a blacklisted/placeholder name `baz`
|
= note: `-D blacklisted-name` implied by `-D warnings`

error: aborting due to 14 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/block_in_if_condition.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ error: this boolean expression can be simplified
|
= note: `-D nonminimal-bool` implied by `-D warnings`

error: aborting due to 5 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/bool_comparison.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ error: equality checks against false can be replaced by a negation
|
= note: `-D bool-comparison` implied by `-D warnings`

error: aborting due to 4 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/booleans.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ help: try
| let _ = c != d || a != b;
| let _ = !(a == b && c == d);

error: aborting due to 13 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/box_vec.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ error: you seem to be trying to use `Box<Vec<T>>`. Consider using just `Vec<T>`
= note: `-D box-vec` implied by `-D warnings`
= help: `Vec<T>` is already on the heap, `Box<Vec<T>>` makes an extra allocation.

error: aborting due to previous error
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/cast.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ error: casting to the same type is unnecessary (`bool` -> `bool`)
|
= note: `-D unnecessary-cast` implied by `-D warnings`

error: aborting due to 45 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/char_lit_as_u8.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ error: casting character literal to u8. `char`s are 4 bytes wide in rust, so cas
= help: Consider using a byte literal instead:
b'a'

error: aborting due to previous error
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/cmp_nan.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
= note: `-D cmp-nan` implied by `-D warnings`

error: aborting due to 12 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/cmp_null.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ error: Comparing with null is better expressed by the .is_null() method
|
= note: `-D cmp-null` implied by `-D warnings`

error: aborting due to 2 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/cmp_owned.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ error: this creates an owned instance just for comparison
|
= note: `-D cmp-owned` implied by `-D warnings`

error: aborting due to 6 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/collapsible_if.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ help: try
| println!("!")
| }

error: aborting due to 13 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/complex_types.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
= note: `-D type-complexity` implied by `-D warnings`

error: aborting due to 15 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/copies.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ error: This else block is redundant.
}


error: aborting due to 2 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/cyclomatic_complexity.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ error: the function has a cyclomatic complexity of 8
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions

error: aborting due to 20 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ error: the function has a cyclomatic complexity of 3
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions

error: aborting due to previous error
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/derive.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ note: consider deriving `Clone` or removing `Copy`
67 | | }
| |_^

error: aborting due to 5 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/diverging_sub_expression.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ error: sub-expression diverges
|
= note: `-D diverging-sub-expression` implied by `-D warnings`

error: aborting due to 6 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/dlist.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct
= note: `-D linkedlist` implied by `-D warnings`
= help: a VecDeque might work

error: aborting due to 6 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/doc.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the doc
|
= note: `-D doc-markdown` implied by `-D warnings`

error: aborting due to 29 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/double_neg.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ error: `--x` could be misinterpreted as pre-decrement by C programmers, is usual
|
= note: `-D double-neg` implied by `-D warnings`

error: aborting due to previous error
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/double_parens.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ error: Consider removing unnecessary double parentheses
|
= note: `-D double-parens` implied by `-D warnings`

error: aborting due to 5 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/drop_forget_copy.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ note: argument has type SomeStruct
42 | forget(s4);
| ^^

error: aborting due to 6 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/drop_forget_ref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ note: argument has type &SomeStruct
59 | std::mem::forget(&SomeStruct);
| ^^^^^^^^^^^

error: aborting due to 18 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/duplicate_underscore_argument.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ error: `darth` already exists, having another argument having almost the same na
|
= note: `-D duplicate-underscore-argument` implied by `-D warnings`

error: aborting due to previous error
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/empty_enum.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ help: consider using the uninhabited type `!` or a wrapper around it
7 | enum Empty {}
| ^^^^^^^^^^^^^

error: aborting due to previous error
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/entry.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ error: usage of `contains_key` followed by `insert` on a `BTreeMap`
|
= note: `-D map-entry` implied by `-D warnings`

error: aborting due to 7 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/enum_glob_use.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ error: don't use glob imports for enum variants
|
= note: `-D enum-glob-use` implied by `-D warnings`

error: aborting due to 2 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
2 changes: 1 addition & 1 deletion clippy_tests/examples/enum_variants.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ error: All variants have the same prefix: `With`
= note: `-D pub-enum-variant-names` implied by `-D warnings`
= help: remove the prefixes and use full paths to the variants instead of glob imports

error: aborting due to 10 previous errors
error: aborting due to previous error(s)

error: Could not compile `clippy_tests`.

Expand Down
Loading