From bec5b69e4550f14310ee8b5cf9c6ac35222d48eb Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Mon, 20 Jan 2020 21:07:31 +0900 Subject: [PATCH] Apply review comment --- clippy_lints/src/methods/mod.rs | 10 +++++++--- tests/ui/skip_while_next.stderr | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 8dfebb56f..013c9deb5 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -2563,9 +2563,13 @@ fn lint_skip_while_next<'a, 'tcx>( ) { // lint if caller of `.skip_while().next()` is an Iterator if match_trait_method(cx, expr, &paths::ITERATOR) { - let msg = "called `skip_while(p).next()` on an `Iterator`. \ - This is more succinctly expressed by calling `.find(!p)` instead."; - span_lint(cx, SKIP_WHILE_NEXT, expr.span, msg); + span_help_and_lint( + cx, + SKIP_WHILE_NEXT, + expr.span, + "called `skip_while(p).next()` on an `Iterator`", + "this is more succinctly expressed by calling `.find(!p)` instead", + ); } } diff --git a/tests/ui/skip_while_next.stderr b/tests/ui/skip_while_next.stderr index 2ce88ac23..a6b7bcd63 100644 --- a/tests/ui/skip_while_next.stderr +++ b/tests/ui/skip_while_next.stderr @@ -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 | LL | let _ = v.iter().skip_while(|&x| *x < 0).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = 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 | LL | let _ = v.iter().skip_while(|&x| { @@ -15,6 +16,8 @@ LL | | *x < 0 LL | | } LL | | ).next(); | |___________________________^ + | + = help: this is more succinctly expressed by calling `.find(!p)` instead error: aborting due to 2 previous errors