about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authormcarton <cartonmartin+git@gmail.com>2016-01-18 19:28:06 +0100
committermcarton <cartonmartin+git@gmail.com>2016-01-18 19:28:06 +0100
commit9d5e9cfd97e69ddef1e25562ecd4d351e655ae17 (patch)
tree0dfdd2b80937ef637eb778a0ac5b0230c6d08d39 /src
parent28b043735468936cc23b4cc7a4ce5ed3246524c8 (diff)
downloadrust-9d5e9cfd97e69ddef1e25562ecd4d351e655ae17.tar.gz
rust-9d5e9cfd97e69ddef1e25562ecd4d351e655ae17.zip
Fix redundant_closure false positive
Diffstat (limited to 'src')
-rw-r--r--src/eta_reduction.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/eta_reduction.rs b/src/eta_reduction.rs
index 46c458c6bcb..fcc1a6893b2 100644
--- a/src/eta_reduction.rs
+++ b/src/eta_reduction.rs
@@ -45,6 +45,7 @@ fn check_closure(cx: &LateContext, expr: &Expr) {
             // || {foo(); bar()}; can't be reduced here
             return;
         }
+
         if let Some(ref ex) = blk.expr {
             if let ExprCall(ref caller, ref args) = ex.node {
                 if args.len() != decl.inputs.len() {
@@ -52,8 +53,8 @@ fn check_closure(cx: &LateContext, expr: &Expr) {
                     // is no way the closure is the same as the function
                     return;
                 }
-                if args.iter().any(|arg| is_adjusted(cx, arg)) {
-                    // Are the arguments type-adjusted? Then we need the closure
+                if is_adjusted(cx, ex) || args.iter().any(|arg| is_adjusted(cx, arg)) {
+                    // Are the expression or the arguments type-adjusted? Then we need the closure
                     return;
                 }
                 let fn_ty = cx.tcx.expr_ty(caller);