about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-01-20 12:12:03 +0000
committerbors <bors@rust-lang.org>2020-01-20 12:12:03 +0000
commit32949da78ee11ae06afb77a68b5c82187a6dd2ab (patch)
treed8e8eb382e86245c711b08746f8b99155d608b39
parent2695f0054632057861101ec3168a0e5090aebfaa (diff)
parentf8034e0bc652b813535e5c412d3cd25a9a175172 (diff)
downloadrust-32949da78ee11ae06afb77a68b5c82187a6dd2ab.tar.gz
rust-32949da78ee11ae06afb77a68b5c82187a6dd2ab.zip
Auto merge of #5070 - JohnTitor:suspicious-map-doc, r=flip1995
Improve `suspicious_map`documentation

Fixes #4793

changelog: none
-rw-r--r--clippy_lints/src/methods/mod.rs5
-rw-r--r--tests/ui/suspicious_map.stderr2
2 files changed, 4 insertions, 3 deletions
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs
index ed37d3411b5..5d3d493476d 100644
--- a/clippy_lints/src/methods/mod.rs
+++ b/clippy_lints/src/methods/mod.rs
@@ -1041,7 +1041,8 @@ 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.
+    /// If the `map` call is intentional, this should be rewritten. Or, if you intend to
+    /// drive the iterator to completion, you can just use `for_each` instead.
     ///
     /// **Known problems:** None
     ///
@@ -3014,7 +3015,7 @@ fn lint_suspicious_map(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>) {
         SUSPICIOUS_MAP,
         expr.span,
         "this call to `map()` won't have an effect on the call to `count()`",
-        "make sure you did not confuse `map` with `filter`",
+        "make sure you did not confuse `map` with `filter` or `for_each`",
     );
 }
 
diff --git a/tests/ui/suspicious_map.stderr b/tests/ui/suspicious_map.stderr
index e6588f4691a..e1b4ba40376 100644
--- a/tests/ui/suspicious_map.stderr
+++ b/tests/ui/suspicious_map.stderr
@@ -5,7 +5,7 @@ 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`
+   = help: make sure you did not confuse `map` with `filter` or `for_each`
 
 error: aborting due to previous error