Skip to content

Commit

Permalink
Disallow async for traits
Browse files Browse the repository at this point in the history
It won't work anyways, checking it in scaffolding generation means that
users will discover this earlier.
  • Loading branch information
jplatte committed Jul 11, 2023
1 parent c9b9ae0 commit b18d6b7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion uniffi_macros/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ pub(crate) fn expand_export(
self_ident,
callback_interface: false,
} => {
if let Some(rt) = args.async_runtime {
return Err(syn::Error::new_spanned(rt, "not supported for traits"));
}

let name = ident_to_string(&self_ident);
let free_fn_ident =
Ident::new(&free_fn_symbol_name(&mod_path, &name), Span::call_site());
Expand All @@ -78,7 +82,15 @@ pub(crate) fn expand_export(
let impl_tokens: TokenStream = items
.into_iter()
.map(|item| match item {
ImplItem::Method(sig) => gen_method_scaffolding(sig, &args),
ImplItem::Method(sig) => {
if sig.is_async {
return Err(syn::Error::new(
sig.span,
"async trait methods are not supported",
));
}
gen_method_scaffolding(sig, &args)
}
_ => unreachable!("traits have no constructors"),
})
.collect::<syn::Result<_>>()?;
Expand Down

0 comments on commit b18d6b7

Please sign in to comment.