diff options
| author | mcarton <cartonmartin+git@gmail.com> | 2016-01-18 19:28:06 +0100 |
|---|---|---|
| committer | mcarton <cartonmartin+git@gmail.com> | 2016-01-18 19:28:06 +0100 |
| commit | 9d5e9cfd97e69ddef1e25562ecd4d351e655ae17 (patch) | |
| tree | 0dfdd2b80937ef637eb778a0ac5b0230c6d08d39 /src | |
| parent | 28b043735468936cc23b4cc7a4ce5ed3246524c8 (diff) | |
| download | rust-9d5e9cfd97e69ddef1e25562ecd4d351e655ae17.tar.gz rust-9d5e9cfd97e69ddef1e25562ecd4d351e655ae17.zip | |
Fix redundant_closure false positive
Diffstat (limited to 'src')
| -rw-r--r-- | src/eta_reduction.rs | 5 |
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); |
