mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Apply review comment
This commit is contained in:
parent
84e4bc54e0
commit
bec5b69e45
2 changed files with 12 additions and 5 deletions
|
@ -2563,9 +2563,13 @@ fn lint_skip_while_next<'a, 'tcx>(
|
||||||
) {
|
) {
|
||||||
// lint if caller of `.skip_while().next()` is an Iterator
|
// lint if caller of `.skip_while().next()` is an Iterator
|
||||||
if match_trait_method(cx, expr, &paths::ITERATOR) {
|
if match_trait_method(cx, expr, &paths::ITERATOR) {
|
||||||
let msg = "called `skip_while(p).next()` on an `Iterator`. \
|
span_help_and_lint(
|
||||||
This is more succinctly expressed by calling `.find(!p)` instead.";
|
cx,
|
||||||
span_lint(cx, SKIP_WHILE_NEXT, expr.span, msg);
|
SKIP_WHILE_NEXT,
|
||||||
|
expr.span,
|
||||||
|
"called `skip_while(p).next()` on an `Iterator`",
|
||||||
|
"this is more succinctly expressed by calling `.find(!p)` instead",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
error: called `skip_while(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(!p)` instead.
|
error: called `skip_while(p).next()` on an `Iterator`
|
||||||
--> $DIR/skip_while_next.rs:14:13
|
--> $DIR/skip_while_next.rs:14:13
|
||||||
|
|
|
|
||||||
LL | let _ = v.iter().skip_while(|&x| *x < 0).next();
|
LL | let _ = v.iter().skip_while(|&x| *x < 0).next();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `-D clippy::skip-while-next` implied by `-D warnings`
|
= note: `-D clippy::skip-while-next` implied by `-D warnings`
|
||||||
|
= help: this is more succinctly expressed by calling `.find(!p)` instead
|
||||||
|
|
||||||
error: called `skip_while(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(!p)` instead.
|
error: called `skip_while(p).next()` on an `Iterator`
|
||||||
--> $DIR/skip_while_next.rs:17:13
|
--> $DIR/skip_while_next.rs:17:13
|
||||||
|
|
|
|
||||||
LL | let _ = v.iter().skip_while(|&x| {
|
LL | let _ = v.iter().skip_while(|&x| {
|
||||||
|
@ -15,6 +16,8 @@ LL | | *x < 0
|
||||||
LL | | }
|
LL | | }
|
||||||
LL | | ).next();
|
LL | | ).next();
|
||||||
| |___________________________^
|
| |___________________________^
|
||||||
|
|
|
||||||
|
= help: this is more succinctly expressed by calling `.find(!p)` instead
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue