Skip to content

Improve suspicious_mapdocumentation #5070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2020
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
5 changes: 3 additions & 2 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down Expand Up @@ -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`",
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/suspicious_map.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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