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:
kennytm 2018-08-21 01:20:12 +08:00 committed by GitHub
commit ffde96c201
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 90 additions and 34 deletions

View file

@ -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 `()`
};
}

View file

@ -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

View file

@ -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