11use clippy_utils:: diagnostics:: { span_lint_and_sugg, span_lint_and_then} ;
22use clippy_utils:: higher:: VecArgs ;
33use clippy_utils:: source:: snippet_opt;
4+ use clippy_utils:: ty:: is_type_diagnostic_item;
45use clippy_utils:: usage:: local_used_after_expr;
56use clippy_utils:: { get_enclosing_loop_or_closure, higher, path_to_local, path_to_local_id} ;
67use if_chain:: if_chain;
@@ -12,6 +13,7 @@ use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
1213use rustc_middle:: ty:: subst:: Subst ;
1314use rustc_middle:: ty:: { self , ClosureKind , Ty , TypeFoldable } ;
1415use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
16+ use rustc_span:: symbol:: sym;
1517
1618declare_clippy_lint ! {
1719 /// ### What it does
@@ -113,6 +115,9 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
113115 // A type param function ref like `T::f` is not 'static, however
114116 // it is if cast like `T::f as fn()`. This seems like a rustc bug.
115117 if !substs. types( ) . any( |t| matches!( t. kind( ) , ty:: Param ( _) ) ) ;
118+ let callee_ty_unadjusted = cx. typeck_results( ) . expr_ty( callee) . peel_refs( ) ;
119+ if !is_type_diagnostic_item( cx, callee_ty_unadjusted, sym:: Arc ) ;
120+ if !is_type_diagnostic_item( cx, callee_ty_unadjusted, sym:: Rc ) ;
116121 then {
117122 span_lint_and_then( cx, REDUNDANT_CLOSURE , expr. span, "redundant closure" , |diag| {
118123 if let Some ( mut snippet) = snippet_opt( cx, callee. span) {
0 commit comments