diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index ff40839637b..1ab13a825da 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -63,7 +63,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub POSSIBLE_MISSING_COMMA, - style, + correctness, "possible missing comma in array" } diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 719708d6d18..cb359daba44 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -24,7 +24,7 @@ use utils::{iter_input_pats, span_lint, type_is_unsafe_function}; /// ``` declare_clippy_lint! { pub TOO_MANY_ARGUMENTS, - style, + complexity, "functions with too many arguments" } diff --git a/clippy_lints/src/inline_fn_without_body.rs b/clippy_lints/src/inline_fn_without_body.rs index 243498d2d4e..af7de542a91 100644 --- a/clippy_lints/src/inline_fn_without_body.rs +++ b/clippy_lints/src/inline_fn_without_body.rs @@ -22,7 +22,7 @@ use utils::sugg::DiagnosticBuilderExt; /// ``` declare_clippy_lint! { pub INLINE_FN_WITHOUT_BODY, - complexity, + correctness, "use of `#[inline]` on trait methods without bodies" } diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 75aa4dfb418..187b1fcee82 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -85,6 +85,9 @@ macro_rules! declare_clippy_lint { { pub $name:tt, internal, $description:tt } => { declare_lint! { pub $name, Allow, $description } }; + { pub $name:tt, internal_warn, $description:tt } => { + declare_lint! { pub $name, Warn, $description } + }; } pub mod consts; @@ -443,7 +446,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { misc::USED_UNDERSCORE_BINDING, misc_early::UNSEPARATED_LITERAL_SUFFIX, mut_mut::MUT_MUT, - mutex_atomic::MUTEX_INTEGER, needless_continue::NEEDLESS_CONTINUE, non_expressive_names::SIMILAR_NAMES, replace_consts::REPLACE_CONSTS, @@ -674,10 +676,8 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { enum_variants::MODULE_INCEPTION, eq_op::OP_REF, eta_reduction::REDUNDANT_CLOSURE, - formatting::POSSIBLE_MISSING_COMMA, formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING, formatting::SUSPICIOUS_ELSE_FORMATTING, - functions::TOO_MANY_ARGUMENTS, if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING, len_zero::LEN_WITHOUT_IS_EMPTY, len_zero::LEN_ZERO, @@ -686,15 +686,10 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { literal_representation::LARGE_DIGIT_GROUPS, literal_representation::UNREADABLE_LITERAL, loops::EMPTY_LOOP, - loops::EXPLICIT_COUNTER_LOOP, loops::EXPLICIT_INTO_ITER_LOOP, loops::EXPLICIT_ITER_LOOP, loops::FOR_KV_MAP, - loops::MANUAL_MEMCPY, loops::NEEDLESS_RANGE_LOOP, - loops::NEVER_LOOP, - loops::UNUSED_COLLECT, - loops::WHILE_LET_LOOP, loops::WHILE_LET_ON_ITERATOR, map_clone::MAP_CLONE, matches::MATCH_BOOL, @@ -703,16 +698,12 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { matches::MATCH_WILD_ERR_ARM, matches::SINGLE_MATCH, methods::CHARS_LAST_CMP, - methods::CHARS_NEXT_CMP, - methods::FILTER_NEXT, methods::GET_UNWRAP, methods::ITER_CLONED_COLLECT, methods::ITER_SKIP_NEXT, methods::NEW_RET_NO_SELF, methods::OK_EXPECT, methods::OPTION_MAP_OR_NONE, - methods::OR_FUN_CALL, - methods::SEARCH_IS_SOME, methods::SHOULD_IMPLEMENT_TRAIT, methods::STRING_EXTEND_CHARS, methods::UNNECESSARY_FOLD, @@ -724,10 +715,8 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { misc_early::DOUBLE_NEG, misc_early::DUPLICATE_UNDERSCORE_ARGUMENT, misc_early::MIXED_CASE_HEX_LITERALS, - misc_early::REDUNDANT_CLOSURE_CALL, misc_early::UNNEEDED_FIELD_PATTERN, mut_reference::UNNECESSARY_MUT_PASSED, - needless_bool::BOOL_COMPARISON, needless_pass_by_value::NEEDLESS_PASS_BY_VALUE, neg_multiply::NEG_MULTIPLY, new_without_default::NEW_WITHOUT_DEFAULT, @@ -763,22 +752,25 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { eval_order_dependence::EVAL_ORDER_DEPENDENCE, explicit_write::EXPLICIT_WRITE, format::USELESS_FORMAT, + functions::TOO_MANY_ARGUMENTS, identity_conversion::IDENTITY_CONVERSION, identity_op::IDENTITY_OP, - inline_fn_without_body::INLINE_FN_WITHOUT_BODY, int_plus_one::INT_PLUS_ONE, lifetimes::NEEDLESS_LIFETIMES, lifetimes::UNUSED_LIFETIMES, - loops::FOR_LOOP_OVER_OPTION, - loops::FOR_LOOP_OVER_RESULT, - loops::ITER_NEXT_LOOP, + loops::EXPLICIT_COUNTER_LOOP, loops::MUT_RANGE_BOUND, + loops::WHILE_LET_LOOP, matches::MATCH_AS_REF, + methods::CHARS_NEXT_CMP, methods::CLONE_ON_COPY, + methods::FILTER_NEXT, + methods::SEARCH_IS_SOME, methods::USELESS_ASREF, - misc::FLOAT_CMP, misc::SHORT_CIRCUIT_STATEMENT, + misc_early::REDUNDANT_CLOSURE_CALL, misc_early::ZERO_PREFIXED_LITERAL, + needless_bool::BOOL_COMPARISON, needless_bool::NEEDLESS_BOOL, needless_borrow::NEEDLESS_BORROW, needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE, @@ -801,7 +793,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { transmute::TRANSMUTE_PTR_TO_REF, transmute::USELESS_TRANSMUTE, types::BORROWED_BOX, - types::BOX_VEC, types::CAST_LOSSLESS, types::CHAR_LIT_AS_U8, types::OPTION_OPTION, @@ -830,15 +821,22 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT, eq_op::EQ_OP, erasing_op::ERASING_OP, + formatting::POSSIBLE_MISSING_COMMA, functions::NOT_UNSAFE_PTR_ARG_DEREF, infinite_iter::INFINITE_ITER, + inline_fn_without_body::INLINE_FN_WITHOUT_BODY, invalid_ref::INVALID_REF, + loops::FOR_LOOP_OVER_OPTION, + loops::FOR_LOOP_OVER_RESULT, + loops::ITER_NEXT_LOOP, + loops::NEVER_LOOP, loops::REVERSE_RANGE_LOOP, loops::WHILE_IMMUTABLE_CONDITION, methods::CLONE_DOUBLE_REF, methods::TEMPORARY_CSTRING_AS_PTR, minmax::MIN_MAX, misc::CMP_NAN, + misc::FLOAT_CMP, misc::MODULO_ONE, open_options::NONSENSICAL_OPEN_OPTIONS, ptr::MUT_FROM_REF, @@ -860,15 +858,20 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { entry::MAP_ENTRY, escape::BOXED_LOCAL, large_enum_variant::LARGE_ENUM_VARIANT, + loops::MANUAL_MEMCPY, + loops::UNUSED_COLLECT, methods::ITER_NTH, + methods::OR_FUN_CALL, methods::SINGLE_CHAR_PATTERN, misc::CMP_OWNED, mutex_atomic::MUTEX_ATOMIC, + types::BOX_VEC, vec::USELESS_VEC, ]); reg.register_lint_group("clippy_nursery", vec![ fallible_impl_from::FALLIBLE_IMPL_FROM, + mutex_atomic::MUTEX_INTEGER, ranges::RANGE_PLUS_ONE, ]); } diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 48b77be662b..6f04940ae31 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -40,7 +40,7 @@ use utils::paths; /// ``` declare_clippy_lint! { pub MANUAL_MEMCPY, - style, + perf, "manually copying items between slices" } @@ -119,7 +119,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub ITER_NEXT_LOOP, - complexity, + correctness, "for-looping over `_.next()` which is probably not intended" } @@ -141,7 +141,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub FOR_LOOP_OVER_OPTION, - complexity, + correctness, "for-looping over an `Option`, which is more clearly expressed as an `if let`" } @@ -163,7 +163,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub FOR_LOOP_OVER_RESULT, - complexity, + correctness, "for-looping over a `Result`, which is more clearly expressed as an `if let`" } @@ -191,7 +191,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub WHILE_LET_LOOP, - style, + complexity, "`loop { if let { ... } else break }`, which can be written as a `while let` loop" } @@ -209,7 +209,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub UNUSED_COLLECT, - style, + perf, "`collect()`ing an iterator without using the result; this is usually better \ written as a for loop" } @@ -252,7 +252,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub EXPLICIT_COUNTER_LOOP, - style, + complexity, "for-looping with an explicit counter when `_.enumerate()` would do" } @@ -329,7 +329,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub NEVER_LOOP, - style, + correctness, "any loop that will always `break` or `return`" } diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index abce4c2d5fb..50de299ca7d 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -160,7 +160,7 @@ declare_clippy_lint! { /// **Why is this bad?** Readability, this can be written more concisely as /// `_.map_or(_, _)`. /// -/// **Known problems:** None. +/// **Known problems:** The order of the arguments is not in execution order /// /// **Example:** /// ```rust @@ -178,7 +178,7 @@ declare_clippy_lint! { /// **Why is this bad?** Readability, this can be written more concisely as /// `_.map_or_else(_, _)`. /// -/// **Known problems:** None. +/// **Known problems:** The order of the arguments is not in execution order. /// /// **Example:** /// ```rust @@ -214,7 +214,7 @@ declare_clippy_lint! { /// **Why is this bad?** Readability, this can be written more concisely as /// `_.and_then(_)`. /// -/// **Known problems:** None. +/// **Known problems:** The order of the arguments is not in execution order. /// /// **Example:** /// ```rust @@ -240,7 +240,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub FILTER_NEXT, - style, + complexity, "using `filter(p).next()`, which is more succinctly expressed as `.find(p)`" } @@ -278,7 +278,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub SEARCH_IS_SOME, - style, + complexity, "using an iterator search followed by `is_some()`, which is more succinctly \ expressed as a call to `any()`" } @@ -297,7 +297,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub CHARS_NEXT_CMP, - style, + complexity, "using `.chars().next()` to check if a string starts with a char" } @@ -325,7 +325,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub OR_FUN_CALL, - style, + perf, "using any `*or` method with a function call, which suggests `*or_else`" } @@ -347,8 +347,8 @@ declare_clippy_lint! { } /// **What it does:** Checks for usage of `.clone()` on a ref-counted pointer, -/// (Rc, Arc, rc::Weak, or sync::Weak), and suggests calling Clone on -/// the corresponding trait instead. +/// (`Rc`, `Arc`, `rc::Weak`, or `sync::Weak`), and suggests calling Clone via unified +/// function syntax instead (e.g. `Rc::clone(foo)`). /// /// **Why is this bad?**: Calling '.clone()' on an Rc, Arc, or Weak /// can obscure the fact that only the pointer is being cloned, not the underlying diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 538a3eaaefd..e9b6865f0c9 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -72,7 +72,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub FLOAT_CMP, - complexity, + correctness, "using `==` or `!=` on float values instead of comparing difference with an epsilon" } diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index 0331c976377..3f3ba6487de 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -54,7 +54,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub REDUNDANT_CLOSURE_CALL, - style, + complexity, "throwaway closures called in the expression they are defined" } diff --git a/clippy_lints/src/mutex_atomic.rs b/clippy_lints/src/mutex_atomic.rs index 77af0be0ec8..b879d76e65c 100644 --- a/clippy_lints/src/mutex_atomic.rs +++ b/clippy_lints/src/mutex_atomic.rs @@ -44,7 +44,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub MUTEX_INTEGER, - pedantic, + nursery, "using a mutex for an integer type" } diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index 393e0ec110c..e88d76656eb 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -44,7 +44,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub BOOL_COMPARISON, - style, + complexity, "comparing a variable to a boolean, e.g. `if x == true`" } diff --git a/clippy_lints/src/print.rs b/clippy_lints/src/print.rs index 7413ab2ac63..6d9880e1335 100644 --- a/clippy_lints/src/print.rs +++ b/clippy_lints/src/print.rs @@ -8,7 +8,7 @@ use syntax_pos::Span; use utils::{is_expn_of, match_def_path, match_path, resolve_node, span_lint, span_lint_and_sugg}; use utils::{opt_def_id, paths}; -/// **What it does:** This lint warns when you using `println!("")` to +/// **What it does:** This lint warns when you use `println!("")` to /// print a newline. /// /// **Why is this bad?** You should use `println!()`, which is simpler. @@ -22,10 +22,10 @@ use utils::{opt_def_id, paths}; declare_clippy_lint! { pub PRINTLN_EMPTY_STRING, style, - "using `print!()` with a format string that ends in a newline" + "using `println!(\"\")` with an empty string" } -/// **What it does:** This lint warns when you using `print!()` with a format +/// **What it does:** This lint warns when you use `print!()` with a format /// string that /// ends in a newline. /// diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index ba7d4bbbe0f..16a1142efb7 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -46,7 +46,7 @@ pub struct TypePass; /// ``` declare_clippy_lint! { pub BOX_VEC, - complexity, + perf, "usage of `Box>`, vector elements are already on the heap" } diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index 2684e3999ab..192d6671bcb 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -40,7 +40,7 @@ use std::collections::HashMap; /// ``` declare_clippy_lint! { pub LINT_AUTHOR, - style, // ok, this is not a style lint, but it's also a noop without the appropriate attribute + internal_warn, "helper for writing lints" } diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index cc98df941e8..e8d07fbed0d 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -26,7 +26,7 @@ use syntax::attr; /// ``` declare_clippy_lint! { pub DEEP_CODE_INSPECTION, - style, // not a style lint, but essentially a noop without the appropriate attribute + internal_warn, "helper to dump info about code" } diff --git a/tests/ui/never_loop.stderr b/tests/ui/never_loop.stderr index 83c10c9b193..664be379e35 100644 --- a/tests/ui/never_loop.stderr +++ b/tests/ui/never_loop.stderr @@ -10,7 +10,7 @@ error: this loop never actually loops 13 | | } | |_____^ | - = note: `-D never-loop` implied by `-D warnings` + = note: #[deny(never_loop)] on by default error: this loop never actually loops --> $DIR/never_loop.rs:28:5