about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJeremy Stucki <jeremy@myelin.ch>2019-08-18 16:49:11 +0200
committerJeremy Stucki <jeremy@myelin.ch>2019-08-18 16:49:11 +0200
commit9c39c02b758c96d94ea1ba648ef77efff2631b86 (patch)
treea546460b21f16acfde97486b91f158216c03a49f
parent5df84f219298026af02910a84e1f08ebd5ef3bbd (diff)
downloadrust-9c39c02b758c96d94ea1ba648ef77efff2631b86.tar.gz
rust-9c39c02b758c96d94ea1ba648ef77efff2631b86.zip
Change lint type to 'complexity'
-rw-r--r--clippy_lints/src/lib.rs3
-rw-r--r--clippy_lints/src/methods/mod.rs10
-rw-r--r--src/lintlist/mod.rs2
-rw-r--r--tests/ui/suspicious_map.stderr3
4 files changed, 11 insertions, 7 deletions
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index 308c3e918e8..705ec2e9fd8 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -657,7 +657,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
         methods::OPTION_MAP_UNWRAP_OR,
         methods::OPTION_MAP_UNWRAP_OR_ELSE,
         methods::RESULT_MAP_UNWRAP_OR_ELSE,
-        methods::SUSPICIOUS_MAP,
         misc::USED_UNDERSCORE_BINDING,
         misc_early::UNSEPARATED_LITERAL_SUFFIX,
         mut_mut::MUT_MUT,
@@ -801,6 +800,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
         methods::SHOULD_IMPLEMENT_TRAIT,
         methods::SINGLE_CHAR_PATTERN,
         methods::STRING_EXTEND_CHARS,
+        methods::SUSPICIOUS_MAP,
         methods::TEMPORARY_CSTRING_AS_PTR,
         methods::UNNECESSARY_FILTER_MAP,
         methods::UNNECESSARY_FOLD,
@@ -1034,6 +1034,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
         methods::FILTER_NEXT,
         methods::FLAT_MAP_IDENTITY,
         methods::SEARCH_IS_SOME,
+        methods::SUSPICIOUS_MAP,
         methods::UNNECESSARY_FILTER_MAP,
         methods::USELESS_ASREF,
         misc::SHORT_CIRCUIT_STATEMENT,
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs
index fc2d2341533..c8e3ca14ab1 100644
--- a/clippy_lints/src/methods/mod.rs
+++ b/clippy_lints/src/methods/mod.rs
@@ -18,7 +18,6 @@ use syntax::ast;
 use syntax::source_map::Span;
 use syntax::symbol::LocalInternedString;
 
-use crate::utils::paths;
 use crate::utils::sugg;
 use crate::utils::usage::mutated_variables;
 use crate::utils::{
@@ -28,6 +27,7 @@ use crate::utils::{
     snippet, snippet_with_applicability, snippet_with_macro_callsite, span_lint, span_lint_and_sugg,
     span_lint_and_then, span_note_and_lint, walk_ptrs_ty, walk_ptrs_ty_depth, SpanlessEq,
 };
+use crate::utils::{paths, span_help_and_lint};
 
 declare_clippy_lint! {
     /// **What it does:** Checks for `.unwrap()` calls on `Option`s.
@@ -893,6 +893,7 @@ declare_clippy_lint! {
     /// **What it does:** Checks for calls to `map` followed by a `count`.
     ///
     /// **Why is this bad?** It looks suspicious. Maybe `map` was confused with `filter`.
+    /// If the `map` call is intentional, this should be rewritten.
     ///
     /// **Known problems:** None
     ///
@@ -902,7 +903,7 @@ declare_clippy_lint! {
     /// let _ = (0..3).map(|x| x + 2).count();
     /// ```
     pub SUSPICIOUS_MAP,
-    pedantic,
+    complexity,
     "suspicious usage of map"
 }
 
@@ -2539,11 +2540,12 @@ fn lint_into_iter(cx: &LateContext<'_, '_>, expr: &hir::Expr, self_ref_ty: Ty<'_
 }
 
 fn lint_suspicious_map(cx: &LateContext<'_, '_>, expr: &hir::Expr) {
-    span_lint(
+    span_help_and_lint(
         cx,
         SUSPICIOUS_MAP,
         expr.span,
-        "Make sure you did not confuse `map` with `filter`.",
+        "this call to `map()` won't have an effect on the call to `count()`",
+        "make sure you did not confuse `map` with `filter`",
     );
 }
 
diff --git a/src/lintlist/mod.rs b/src/lintlist/mod.rs
index 36a45f705e7..ff7db0a3da7 100644
--- a/src/lintlist/mod.rs
+++ b/src/lintlist/mod.rs
@@ -1738,7 +1738,7 @@ pub const ALL_LINTS: [Lint; 310] = [
     },
     Lint {
         name: "suspicious_map",
-        group: "pedantic",
+        group: "complexity",
         desc: "suspicious usage of map",
         deprecation: None,
         module: "methods",
diff --git a/tests/ui/suspicious_map.stderr b/tests/ui/suspicious_map.stderr
index 434ea089fed..e6588f4691a 100644
--- a/tests/ui/suspicious_map.stderr
+++ b/tests/ui/suspicious_map.stderr
@@ -1,10 +1,11 @@
-error: Make sure you did not confuse `map` with `filter`.
+error: this call to `map()` won't have an effect on the call to `count()`
   --> $DIR/suspicious_map.rs:4:13
    |
 LL |     let _ = (0..3).map(|x| x + 2).count();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `-D clippy::suspicious-map` implied by `-D warnings`
+   = help: make sure you did not confuse `map` with `filter`
 
 error: aborting due to previous error