]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/clippy_lints/src/methods/skip_while_next.rs
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / src / tools / clippy / clippy_lints / src / methods / skip_while_next.rs
CommitLineData
f20569fa
XL
1use crate::utils::{match_trait_method, paths, span_lint_and_help};
2use rustc_hir as hir;
3use rustc_lint::LateContext;
4
5use super::SKIP_WHILE_NEXT;
6
7/// lint use of `skip_while().next()` for `Iterators`
8pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, _skip_while_args: &'tcx [hir::Expr<'_>]) {
9 // lint if caller of `.skip_while().next()` is an Iterator
10 if match_trait_method(cx, expr, &paths::ITERATOR) {
11 span_lint_and_help(
12 cx,
13 SKIP_WHILE_NEXT,
14 expr.span,
15 "called `skip_while(<p>).next()` on an `Iterator`",
16 None,
17 "this is more succinctly expressed by calling `.find(!<p>)` instead",
18 );
19 }
20}