1 use clippy_utils::diagnostics::span_lint_and_help;
2 use clippy_utils::is_trait_method;
4 use rustc_lint::LateContext;
9 /// lint use of `filter_map().flat_map()` for `Iterators`
10 pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
11 // lint if caller of `.filter_map().flat_map()` is an Iterator
12 if is_trait_method(cx, expr, sym::Iterator) {
13 let msg = "called `filter_map(..).flat_map(..)` on an `Iterator`";
14 let hint = "this is more succinctly expressed by calling `.flat_map(..)` \
15 and filtering by returning `iter::empty()`";
16 span_lint_and_help(cx, FILTER_MAP, expr.span, msg, None, hint);