]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/clippy_lints/src/methods/skip_while_next.rs
Rollup merge of #105161 - cassaundra:numeric-literal-error, r=nnethercote
[rust.git] / src / tools / clippy / clippy_lints / src / methods / skip_while_next.rs
1 use clippy_utils::diagnostics::span_lint_and_help;
2 use clippy_utils::is_trait_method;
3 use rustc_hir as hir;
4 use rustc_lint::LateContext;
5 use rustc_span::sym;
6
7 use super::SKIP_WHILE_NEXT;
8
9 /// lint use of `skip_while().next()` for `Iterators`
10 pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
11     // lint if caller of `.skip_while().next()` is an Iterator
12     if is_trait_method(cx, expr, sym::Iterator) {
13         span_lint_and_help(
14             cx,
15             SKIP_WHILE_NEXT,
16             expr.span,
17             "called `skip_while(<p>).next()` on an `Iterator`",
18             None,
19             "this is more succinctly expressed by calling `.find(!<p>)` instead",
20         );
21     }
22 }