2021-02-21 17:12:17 +00:00
|
|
|
use super::ITER_NEXT_LOOP;
|
|
|
|
use rustc_hir::Expr;
|
|
|
|
use rustc_lint::LateContext;
|
2021-03-12 17:09:19 +00:00
|
|
|
use rustc_span::sym;
|
|
|
|
|
|
|
|
use crate::utils::{is_trait_method, span_lint};
|
2021-02-21 17:12:17 +00:00
|
|
|
|
2021-03-02 03:41:06 +00:00
|
|
|
pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>, expr: &Expr<'_>) -> bool {
|
2021-03-12 17:09:19 +00:00
|
|
|
if is_trait_method(cx, arg, sym::Iterator) {
|
2021-03-02 03:41:06 +00:00
|
|
|
span_lint(
|
|
|
|
cx,
|
|
|
|
ITER_NEXT_LOOP,
|
|
|
|
expr.span,
|
|
|
|
"you are iterating over `Iterator::next()` which is an Option; this will compile but is \
|
|
|
|
probably not what you want",
|
|
|
|
);
|
|
|
|
true
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
}
|
2021-02-21 17:12:17 +00:00
|
|
|
}
|