]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | use crate::utils::{match_trait_method, paths, span_lint_and_help}; |
2 | use rustc_hir as hir; | |
3 | use rustc_lint::LateContext; | |
4 | ||
5 | use super::SKIP_WHILE_NEXT; | |
6 | ||
7 | /// lint use of `skip_while().next()` for `Iterators` | |
8 | pub(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 | } |