]>
Commit | Line | Data |
---|---|---|
f20569fa | 1 | use super::ITER_NEXT_LOOP; |
cdc7bbd5 XL |
2 | use clippy_utils::diagnostics::span_lint; |
3 | use clippy_utils::is_trait_method; | |
f20569fa XL |
4 | use rustc_hir::Expr; |
5 | use rustc_lint::LateContext; | |
cdc7bbd5 | 6 | use rustc_span::sym; |
f20569fa | 7 | |
2b03887a | 8 | pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>) { |
cdc7bbd5 | 9 | if is_trait_method(cx, arg, sym::Iterator) { |
f20569fa XL |
10 | span_lint( |
11 | cx, | |
12 | ITER_NEXT_LOOP, | |
c295e0f8 | 13 | arg.span, |
f20569fa XL |
14 | "you are iterating over `Iterator::next()` which is an Option; this will compile but is \ |
15 | probably not what you want", | |
16 | ); | |
f20569fa XL |
17 | } |
18 | } |