Skip to content

Commit b18d6b7

Browse files
committed
Disallow async for traits
It won't work anyways, checking it in scaffolding generation means that users will discover this earlier.
1 parent c9b9ae0 commit b18d6b7

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

uniffi_macros/src/export.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ pub(crate) fn expand_export(
5656
self_ident,
5757
callback_interface: false,
5858
} => {
59+
if let Some(rt) = args.async_runtime {
60+
return Err(syn::Error::new_spanned(rt, "not supported for traits"));
61+
}
62+
5963
let name = ident_to_string(&self_ident);
6064
let free_fn_ident =
6165
Ident::new(&free_fn_symbol_name(&mod_path, &name), Span::call_site());
@@ -78,7 +82,15 @@ pub(crate) fn expand_export(
7882
let impl_tokens: TokenStream = items
7983
.into_iter()
8084
.map(|item| match item {
81-
ImplItem::Method(sig) => gen_method_scaffolding(sig, &args),
85+
ImplItem::Method(sig) => {
86+
if sig.is_async {
87+
return Err(syn::Error::new(
88+
sig.span,
89+
"async trait methods are not supported",
90+
));
91+
}
92+
gen_method_scaffolding(sig, &args)
93+
}
8294
_ => unreachable!("traits have no constructors"),
8395
})
8496
.collect::<syn::Result<_>>()?;

0 commit comments

Comments
 (0)