1 use crate::utils::{match_trait_method, paths, span_lint_and_help};
3 use rustc_lint::LateContext;
7 /// lint use of `filter_map().map()` for `Iterators`
8 pub(super) fn check<'tcx>(
9 cx: &LateContext<'tcx>,
10 expr: &'tcx hir::Expr<'_>,
11 _filter_args: &'tcx [hir::Expr<'_>],
12 _map_args: &'tcx [hir::Expr<'_>],
14 // lint if caller of `.filter_map().map()` is an Iterator
15 if match_trait_method(cx, expr, &paths::ITERATOR) {
16 let msg = "called `filter_map(..).map(..)` on an `Iterator`";
17 let hint = "this is more succinctly expressed by only calling `.filter_map(..)` instead";
18 span_lint_and_help(cx, FILTER_MAP, expr.span, msg, None, hint);