mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-22 11:03:16 +00:00
21 lines
598 B
Rust
21 lines
598 B
Rust
use super::ITER_NEXT_LOOP;
|
|
use clippy_utils::diagnostics::span_lint;
|
|
use clippy_utils::is_trait_method;
|
|
use rustc_hir::Expr;
|
|
use rustc_lint::LateContext;
|
|
use rustc_span::sym;
|
|
|
|
pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>, expr: &Expr<'_>) -> bool {
|
|
if is_trait_method(cx, arg, sym::Iterator) {
|
|
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
|
|
}
|
|
}
|