1 use clippy_utils::diagnostics::span_lint_and_help;
2 use clippy_utils::is_trait_method;
4 use rustc_lint::LateContext;
5 use rustc_span::{source_map::Span, sym};
7 use super::INSPECT_FOR_EACH;
9 /// lint use of `inspect().for_each()` for `Iterators`
10 pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, inspect_span: Span) {
11 if is_trait_method(cx, expr, sym::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()),