fix [redundant_closure] suggesting incorrect code with F: Fn()
This commit is contained in:
parent
722de3b546
commit
db30f6ce9f
4 changed files with 54 additions and 9 deletions
|
|
@ -471,3 +471,14 @@ mod issue_10854 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod issue_12853 {
|
||||
fn f_by_value<F: Fn(u32)>(f: F) {
|
||||
let x = Box::new(|| None.map(&f));
|
||||
x();
|
||||
}
|
||||
fn f_by_ref<F: Fn(u32)>(f: &F) {
|
||||
let x = Box::new(|| None.map(f));
|
||||
x();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -471,3 +471,14 @@ mod issue_10854 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod issue_12853 {
|
||||
fn f_by_value<F: Fn(u32)>(f: F) {
|
||||
let x = Box::new(|| None.map(|x| f(x)));
|
||||
x();
|
||||
}
|
||||
fn f_by_ref<F: Fn(u32)>(f: &F) {
|
||||
let x = Box::new(|| None.map(|x| f(x)));
|
||||
x();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,5 +190,17 @@ error: redundant closure
|
|||
LL | test.map(|t| t.method())
|
||||
| ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `crate::issue_10854::d::Test::method`
|
||||
|
||||
error: aborting due to 31 previous errors
|
||||
error: redundant closure
|
||||
--> tests/ui/eta.rs:477:38
|
||||
|
|
||||
LL | let x = Box::new(|| None.map(|x| f(x)));
|
||||
| ^^^^^^^^ help: replace the closure with the function itself: `&f`
|
||||
|
||||
error: redundant closure
|
||||
--> tests/ui/eta.rs:481:38
|
||||
|
|
||||
LL | let x = Box::new(|| None.map(|x| f(x)));
|
||||
| ^^^^^^^^ help: replace the closure with the function itself: `f`
|
||||
|
||||
error: aborting due to 33 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue