2 use rustc_lint::LateContext;
3 use rustc_span::source_map::Span;
5 use crate::utils::{match_trait_method, paths, span_lint_and_help};
7 use super::INSPECT_FOR_EACH;
9 /// lint use of `inspect().for_each()` for `Iterators`
10 pub(super) fn lint<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, inspect_span: Span) {
11 if match_trait_method(cx, expr, &paths::ITERATOR) {
12 let msg = "called `inspect(..).for_each(..)` on an `Iterator`";
13 let hint = "move the code from `inspect(..)` to `for_each(..)` and remove the `inspect(..)`";
17 inspect_span.with_hi(expr.span.hi()),