Skip to content

Commit

Permalink
Tweak a suggestion message of needless_for_each
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-Nak committed Mar 15, 2021
1 parent 8e3d769 commit 0e42112
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 5 additions & 11 deletions clippy_lints/src/needless_for_each.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,12 @@ impl LateLintPass<'_> for NeedlessForEach {
snippet_with_applicability(cx, body.value.span, "..", &mut applicability),
);

span_lint_and_then(
cx,
NEEDLESS_FOR_EACH,
stmt.span,
"needless use of `for_each`",
|diag| {
diag.span_suggestion(stmt.span, "try", sugg, applicability);
if let Some(ret_suggs) = ret_suggs {
diag.multipart_suggestion("try replacing `return` with `continue`", ret_suggs, applicability);
}
span_lint_and_then(cx, NEEDLESS_FOR_EACH, stmt.span, "needless use of `for_each`", |diag| {
diag.span_suggestion(stmt.span, "try", sugg, applicability);
if let Some(ret_suggs) = ret_suggs {
diag.multipart_suggestion("...and replace `return` with `continue`", ret_suggs, applicability);
}
)
})
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/needless_for_each_unfixable.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LL | } else {
LL | println!("{}", v);
LL | }
...
help: try replacing `return` with `continue`
help: ...and replace `return` with `continue`
|
LL | continue;
| ^^^^^^^^
Expand Down

0 comments on commit 0e42112

Please sign in to comment.