diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2023-06-09 18:59:24 -0400 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2023-07-30 01:19:36 -0400 |
| commit | 7423c2760b0dbfd4379d2c3eac309d660b859f41 (patch) | |
| tree | af0155573973bac403b758f79527209a3bd3cc51 | |
| parent | 4d80a2ed2e1cd6df90f89d8f39bdfba06c8632fe (diff) | |
| download | rust-7423c2760b0dbfd4379d2c3eac309d660b859f41.tar.gz rust-7423c2760b0dbfd4379d2c3eac309d660b859f41.zip | |
Don't lint redundant closure for any function call inserted by the compiler.
| -rw-r--r-- | clippy_lints/src/eta_reduction.rs | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 255859da495..8d6fb8438b6 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -6,7 +6,7 @@ use clippy_utils::usage::{local_used_after_expr, local_used_in}; use clippy_utils::{higher, is_adjusted, path_to_local, path_to_local_id}; use rustc_errors::Applicability; use rustc_hir::def_id::DefId; -use rustc_hir::{BindingAnnotation, Expr, ExprKind, FnRetTy, Param, PatKind, TyKind, Unsafety}; +use rustc_hir::{BindingAnnotation, Expr, ExprKind, FnRetTy, Param, PatKind, QPath, TyKind, Unsafety}; use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{ @@ -119,16 +119,8 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction { match body.value.kind { ExprKind::Call(callee, args) - if matches!(callee.kind, ExprKind::Path(..)) => + if matches!(callee.kind, ExprKind::Path(QPath::Resolved(..) | QPath::TypeRelative(..))) => { - if matches!(higher::Range::hir(body.value), Some(higher::Range { - start: Some(_), - end: Some(_), - limits: rustc_ast::RangeLimits::Closed - })) { - return; - } - let callee_ty = typeck.expr_ty(callee).peel_refs(); if matches!( type_diagnostic_name(cx, callee_ty), |
