2021-03-12 15:30:50 +01:00
|
|
|
use super::ITER_NEXT_LOOP;
|
2021-03-25 19:29:11 +01:00
|
|
|
use clippy_utils::diagnostics::span_lint;
|
|
|
|
use clippy_utils::is_trait_method;
|
2021-03-12 15:30:50 +01:00
|
|
|
use rustc_hir::Expr;
|
|
|
|
use rustc_lint::LateContext;
|
2021-03-25 19:29:11 +01:00
|
|
|
use rustc_span::sym;
|
2021-03-12 15:30:50 +01:00
|
|
|
|
2022-10-07 17:08:29 +00:00
|
|
|
pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>) {
|
2021-03-25 19:29:11 +01:00
|
|
|
if is_trait_method(cx, arg, sym::Iterator) {
|
2021-03-12 15:30:50 +01:00
|
|
|
span_lint(
|
|
|
|
cx,
|
|
|
|
ITER_NEXT_LOOP,
|
2021-09-06 23:30:04 -07:00
|
|
|
arg.span,
|
2021-03-12 15:30:50 +01:00
|
|
|
"you are iterating over `Iterator::next()` which is an Option; this will compile but is \
|
|
|
|
probably not what you want",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|