Skip to content

Commit c39925d

Browse files
authored
Merge pull request #488 from dtolnay/async
Improve async fn error message with link to workaround
2 parents bf1000f + 8de461f commit c39925d

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

syntax/parse.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ fn parse_extern_fn(
373373
"variadic function is not supported yet",
374374
));
375375
}
376+
if foreign_fn.sig.asyncness.is_some() {
377+
return Err(Error::new_spanned(
378+
foreign_fn,
379+
"async function is not directly supported yet, but see https://cxx.rs/async.html for a working approach",
380+
));
381+
}
376382

377383
let mut doc = Doc::new();
378384
let mut cxx_name = None;

tests/ui/async_fn.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#[cxx::bridge]
2+
mod ffi {
3+
extern "Rust" {
4+
async fn f();
5+
}
6+
}
7+
8+
async fn f() {}
9+
10+
fn main() {}

tests/ui/async_fn.stderr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
error: async function is not directly supported yet, but see https://cxx.rs/async.html for a working approach
2+
--> $DIR/async_fn.rs:4:9
3+
|
4+
4 | async fn f();
5+
| ^^^^^^^^^^^^^

0 commit comments

Comments
 (0)