Skip to content
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

Merged
merged 4 commits into from
Jul 13, 2022

Conversation

itegulov
Copy link
Contributor

Fixes #853

@itegulov itegulov changed the title Support #[handle_result] in ABI macro fix: support #[handle_result] in ABI macro Jun 28, 2022
Comment on lines +131 to +139
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();
};
Copy link
Contributor

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

Copy link
Contributor Author

@itegulov itegulov Jul 13, 2022

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.

@itegulov itegulov merged commit 11f6086 into master Jul 13, 2022
@itegulov itegulov deleted the daniyar/abi-handle-result branch July 13, 2022 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove requirement of Error type being JsonSchema for #[handle_result] errors
3 participants