1 use clippy_utils::diagnostics::span_lint_and_sugg;
2 use clippy_utils::ty::is_type_diagnostic_item;
3 use clippy_utils::{is_expr_identity_function, is_trait_method};
4 use rustc_errors::Applicability;
6 use rustc_lint::LateContext;
7 use rustc_span::{source_map::Span, sym};
9 use super::MAP_IDENTITY;
14 caller: &hir::Expr<'_>,
15 map_arg: &hir::Expr<'_>,
18 let caller_ty = cx.typeck_results().expr_ty(caller);
21 if is_trait_method(cx, expr, sym::Iterator)
22 || is_type_diagnostic_item(cx, caller_ty, sym::Result)
23 || is_type_diagnostic_item(cx, caller_ty, sym::Option);
24 if is_expr_identity_function(cx, map_arg);
25 if let Some(sugg_span) = expr.span.trim_start(caller.span);
31 "unnecessary map of the identity function",
32 "remove the call to `map`",
34 Applicability::MachineApplicable,