Rollup merge of #53296 - estebank:suggest-closure, r=KodrAus
When closure with no arguments was expected, suggest wrapping Fix #49694.
This commit is contained in:
commit
ffde96c201
14 changed files with 90 additions and 34 deletions
|
|
@ -16,6 +16,6 @@ fn main() {
|
|||
let ptr: *mut () = 0 as *mut _;
|
||||
let _: &mut Fn() = unsafe {
|
||||
&mut *(ptr as *mut Fn())
|
||||
//~^ ERROR `(): std::ops::Fn<()>` is not satisfied
|
||||
//~^ ERROR expected a `std::ops::Fn<()>` closure, found `()`
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
error[E0277]: the trait bound `(): std::ops::Fn<()>` is not satisfied
|
||||
error[E0277]: expected a `std::ops::Fn<()>` closure, found `()`
|
||||
--> $DIR/issue-22034.rs:18:16
|
||||
|
|
||||
LL | &mut *(ptr as *mut Fn())
|
||||
| ^^^ the trait `std::ops::Fn<()>` is not implemented for `()`
|
||||
| ^^^ expected an `Fn<()>` closure, found `()`
|
||||
|
|
||||
= help: the trait `std::ops::Fn<()>` is not implemented for `()`
|
||||
= note: wrap the `()` in a closure with no arguments: `|| { /* code */ }
|
||||
= note: required for the cast to the object type `dyn std::ops::Fn()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
error[E0277]: the trait bound `(): std::ops::FnMut<(_, char)>` is not satisfied
|
||||
error[E0277]: expected a `std::ops::FnMut<(_, char)>` closure, found `()`
|
||||
--> $DIR/issue-23966.rs:12:16
|
||||
|
|
||||
LL | "".chars().fold(|_, _| (), ());
|
||||
| ^^^^ the trait `std::ops::FnMut<(_, char)>` is not implemented for `()`
|
||||
| ^^^^ expected an `FnMut<(_, char)>` closure, found `()`
|
||||
|
|
||||
= help: the trait `std::ops::FnMut<(_, char)>` is not implemented for `()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue