mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Merge pull request #559 from mcarton/redundant_closure
Fix redundant_closure false positive
This commit is contained in:
commit
5623e9e601
2 changed files with 7 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -21,6 +21,10 @@ fn main() {
|
|||
unsafe {
|
||||
Some(1u8).map(|a| unsafe_fn(a)); // unsafe fn
|
||||
}
|
||||
|
||||
// See #515
|
||||
let a: Option<Box<::std::ops::Deref<Target = [i32]>>> =
|
||||
Some(vec![1i32, 2]).map(|v| -> Box<::std::ops::Deref<Target = [i32]>> { Box::new(v) });
|
||||
}
|
||||
|
||||
fn meta<F>(f: F) where F: Fn(u8) {
|
||||
|
|
Loading…
Reference in a new issue