Skip to content

Commit 0e42112

Browse files
committed
Tweak a suggestion message of needless_for_each
1 parent 8e3d769 commit 0e42112

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

clippy_lints/src/needless_for_each.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,12 @@ impl LateLintPass<'_> for NeedlessForEach {
104104
snippet_with_applicability(cx, body.value.span, "..", &mut applicability),
105105
);
106106

107-
span_lint_and_then(
108-
cx,
109-
NEEDLESS_FOR_EACH,
110-
stmt.span,
111-
"needless use of `for_each`",
112-
|diag| {
113-
diag.span_suggestion(stmt.span, "try", sugg, applicability);
114-
if let Some(ret_suggs) = ret_suggs {
115-
diag.multipart_suggestion("try replacing `return` with `continue`", ret_suggs, applicability);
116-
}
107+
span_lint_and_then(cx, NEEDLESS_FOR_EACH, stmt.span, "needless use of `for_each`", |diag| {
108+
diag.span_suggestion(stmt.span, "try", sugg, applicability);
109+
if let Some(ret_suggs) = ret_suggs {
110+
diag.multipart_suggestion("...and replace `return` with `continue`", ret_suggs, applicability);
117111
}
118-
)
112+
})
119113
}
120114
}
121115
}

tests/ui/needless_for_each_unfixable.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LL | } else {
2020
LL | println!("{}", v);
2121
LL | }
2222
...
23-
help: try replacing `return` with `continue`
23+
help: ...and replace `return` with `continue`
2424
|
2525
LL | continue;
2626
| ^^^^^^^^

0 commit comments

Comments
 (0)