blob: 8b85f9dde6c92be7507116acf30daa6e45fb621e [file]
use super::ITER_NEXT_LOOP;
use clippy_utils::diagnostics::span_lint;
use clippy_utils::res::{MaybeDef as _, MaybeTypeckRes as _};
use rustc_hir::Expr;
use rustc_lint::LateContext;
use rustc_span::sym;
pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>) {
if cx.ty_based_def(arg).opt_parent(cx).is_diag_item(cx, sym::Iterator) {
span_lint(
cx,
ITER_NEXT_LOOP,
arg.span,
"you are iterating over `Iterator::next()` which is an Option; this will compile but is \
probably not what you want",
);
}
}