Improve async fn error message with link to workaround

This commit is contained in:
David Tolnay 2020-11-19 13:46:14 -08:00
parent 7c5c7bef34
commit 8de461f44a
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 9 additions and 20 deletions

View File

@ -373,6 +373,12 @@ fn parse_extern_fn(
"variadic function is not supported yet",
));
}
if foreign_fn.sig.asyncness.is_some() {
return Err(Error::new_spanned(
foreign_fn,
"async function is not directly supported yet, but see https://cxx.rs/async.html for a working approach",
));
}
let mut doc = Doc::new();
let mut cxx_name = None;

View File

@ -1,22 +1,5 @@
error[E0308]: mismatched types
--> $DIR/async_fn.rs:4:18
error: async function is not directly supported yet, but see https://cxx.rs/async.html for a working approach
--> $DIR/async_fn.rs:4:9
|
4 | async fn f();
| ^
| |
| expected `()`, found opaque type
| possibly return type missing here?
...
8 | async fn f() {}
| - the `Output` of this `async fn`'s found opaque type
|
= note: expected unit type `()`
found opaque type `impl Future`
help: consider `await`ing on the `Future`
|
4 | async fn f.await();
| ^^^^^^
help: try adding a semicolon
|
4 | async fn f;();
| ^
| ^^^^^^^^^^^^^