-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: support #[handle_result]
in ABI macro
#858
Conversation
#[handle_result]
in ABI macro#[handle_result]
in ABI macro
let ty = if let Some(ty) = utils::extract_ok_type(ty) { | ||
ty | ||
} else { | ||
return syn::Error::new_spanned( | ||
ty, | ||
"Function marked with #[handle_result] should have return type Result<T, E> (where E implements FunctionError).", | ||
) | ||
.into_compile_error(); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feels like this is code duplication from the extraction from non-abi codegen, but probably fine for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I kind of feel like the bindgen macro needs a pre-processing step that would do all of these "type" checks (#[handle_result]
, #[callback_vec]
etc) and produce a well-formed model. In this case, it would look something like this:
enum BindgenReturnType {
Regular(Ident),
HandleResult { ident: Ident, ok_type: Ident, err_type: Ident },
}
struct BindgenFunction {
...
return_type: BindgenReturnType
}
So that we can just safely use these models in later steps.
Fixes #853