]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/clippy_lints/src/methods/skip_while_next.rs
bump version to 1.80.1+dfsg1-1~bpo12+pve1
[rustc.git] / src / tools / clippy / clippy_lints / src / methods / skip_while_next.rs
CommitLineData
cdc7bbd5
XL
1use clippy_utils::diagnostics::span_lint_and_help;
2use clippy_utils::is_trait_method;
f20569fa
XL
3use rustc_hir as hir;
4use rustc_lint::LateContext;
cdc7bbd5 5use rustc_span::sym;
f20569fa
XL
6
7use super::SKIP_WHILE_NEXT;
8
9/// lint use of `skip_while().next()` for `Iterators`
cdc7bbd5 10pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
f20569fa 11 // lint if caller of `.skip_while().next()` is an Iterator
cdc7bbd5 12 if is_trait_method(cx, expr, sym::Iterator) {
f20569fa
XL
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}