wiggle: introduce wiggle::Trap, which can be either a String or I32

also, make noreturn functions always return a Trap

wasmtime-wiggle can trivially turn a wiggle::Trap into a wasmtime::Trap.
lucet will have to do the same.
This commit is contained in:
Pat Hickey
2021-01-05 18:19:31 -08:00
parent 4018a06da2
commit f8f9b14c6f
5 changed files with 70 additions and 46 deletions

View File

@@ -40,7 +40,7 @@ pub fn generate(doc: &witx::Document, names: &Names, errs: &ErrorTransform) -> T
let abi_typename = names.type_ref(&errtype.abi_type(), anon_lifetime());
let user_typename = errtype.typename();
let methodname = names.user_error_conversion_method(&errtype);
quote!(fn #methodname(&self, e: super::#user_typename) -> Result<#abi_typename, String>;)
quote!(fn #methodname(&self, e: super::#user_typename) -> Result<#abi_typename, wiggle::Trap>;)
});
let user_error_conversion = quote! {
pub trait UserErrorConversion {