]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/clippy_lints/src/loops/iter_next_loop.rs
merge rustc history
[rust.git] / src / tools / clippy / clippy_lints / src / loops / iter_next_loop.rs
1 use super::ITER_NEXT_LOOP;
2 use clippy_utils::diagnostics::span_lint;
3 use clippy_utils::is_trait_method;
4 use rustc_hir::Expr;
5 use rustc_lint::LateContext;
6 use rustc_span::sym;
7
8 pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>) -> bool {
9     if is_trait_method(cx, arg, sym::Iterator) {
10         span_lint(
11             cx,
12             ITER_NEXT_LOOP,
13             arg.span,
14             "you are iterating over `Iterator::next()` which is an Option; this will compile but is \
15             probably not what you want",
16         );
17         true
18     } else {
19         false
20     }
21 }