Skip to content

Commit bec5b69

Browse files
committed
Apply review comment
1 parent 84e4bc5 commit bec5b69

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

clippy_lints/src/methods/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -2563,9 +2563,13 @@ fn lint_skip_while_next<'a, 'tcx>(
25632563
) {
25642564
// lint if caller of `.skip_while().next()` is an Iterator
25652565
if match_trait_method(cx, expr, &paths::ITERATOR) {
2566-
let msg = "called `skip_while(p).next()` on an `Iterator`. \
2567-
This is more succinctly expressed by calling `.find(!p)` instead.";
2568-
span_lint(cx, SKIP_WHILE_NEXT, expr.span, msg);
2566+
span_help_and_lint(
2567+
cx,
2568+
SKIP_WHILE_NEXT,
2569+
expr.span,
2570+
"called `skip_while(p).next()` on an `Iterator`",
2571+
"this is more succinctly expressed by calling `.find(!p)` instead",
2572+
);
25692573
}
25702574
}
25712575

tests/ui/skip_while_next.stderr

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
error: called `skip_while(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(!p)` instead.
1+
error: called `skip_while(p).next()` on an `Iterator`
22
--> $DIR/skip_while_next.rs:14:13
33
|
44
LL | let _ = v.iter().skip_while(|&x| *x < 0).next();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::skip-while-next` implied by `-D warnings`
8+
= help: this is more succinctly expressed by calling `.find(!p)` instead
89

9-
error: called `skip_while(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(!p)` instead.
10+
error: called `skip_while(p).next()` on an `Iterator`
1011
--> $DIR/skip_while_next.rs:17:13
1112
|
1213
LL | let _ = v.iter().skip_while(|&x| {
@@ -15,6 +16,8 @@ LL | | *x < 0
1516
LL | | }
1617
LL | | ).next();
1718
| |___________________________^
19+
|
20+
= help: this is more succinctly expressed by calling `.find(!p)` instead
1821

1922
error: aborting due to 2 previous errors
2023

0 commit comments

Comments
 (0)