Skip to content

Commit 32949da

Browse files
committed
Auto merge of #5070 - JohnTitor:suspicious-map-doc, r=flip1995
Improve `suspicious_map`documentation Fixes #4793 changelog: none
2 parents 2695f00 + f8034e0 commit 32949da

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

clippy_lints/src/methods/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,8 @@ declare_clippy_lint! {
10411041
/// **What it does:** Checks for calls to `map` followed by a `count`.
10421042
///
10431043
/// **Why is this bad?** It looks suspicious. Maybe `map` was confused with `filter`.
1044-
/// If the `map` call is intentional, this should be rewritten.
1044+
/// If the `map` call is intentional, this should be rewritten. Or, if you intend to
1045+
/// drive the iterator to completion, you can just use `for_each` instead.
10451046
///
10461047
/// **Known problems:** None
10471048
///
@@ -3014,7 +3015,7 @@ fn lint_suspicious_map(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>) {
30143015
SUSPICIOUS_MAP,
30153016
expr.span,
30163017
"this call to `map()` won't have an effect on the call to `count()`",
3017-
"make sure you did not confuse `map` with `filter`",
3018+
"make sure you did not confuse `map` with `filter` or `for_each`",
30183019
);
30193020
}
30203021

tests/ui/suspicious_map.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | let _ = (0..3).map(|x| x + 2).count();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::suspicious-map` implied by `-D warnings`
8-
= help: make sure you did not confuse `map` with `filter`
8+
= help: make sure you did not confuse `map` with `filter` or `for_each`
99

1010
error: aborting due to previous error
1111

0 commit comments

Comments
 (0)