-
Notifications
You must be signed in to change notification settings - Fork 278
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
[feature] #2488: Add support for trait impls in ffi_export
#2601
[feature] #2488: Add support for trait impls in ffi_export
#2601
Conversation
Codecov Report
@@ Coverage Diff @@
## iroha2-dev #2601 +/- ##
==============================================
- Coverage 67.61% 65.88% -1.73%
==============================================
Files 140 156 +16
Lines 26173 28155 +1982
==============================================
+ Hits 17696 18550 +854
- Misses 8477 9605 +1128
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
7d62ecf
to
883307d
Compare
883307d
to
f157ec0
Compare
ffi/derive/src/impl_visitor.rs
Outdated
if self.trait_name.is_none() && !matches!(node.vis, syn::Visibility::Public(_)) { | ||
abort!( | ||
node.vis, | ||
"Methods defined in the inherit impl block must be public" |
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.
"Methods defined in the inherit impl block must be public" | |
"Methods defined in the inherent `impl` block must be public" |
On another note, I'd actually prefer if you just skipped them, instead of failing to compile. Notify via https://docs.rs/proc-macro-error/latest/proc_macro_error/macro.emit_warning.html
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.
We are abort
ing execution all over the place (i mean ffi_export/import
macros) where we don't support such item.
What benefits will we get if we skip private functions?
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.
Basically, you wouldn't force the user to add the function elsewhere. A private function is perfectly valid code, while it shouldn't be reflected in the ffi export, forcing people to have multiple inherent impls is not good design.
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.
Ok, in this case we should make impl
blocks more permissive in general, skip consts, types, ... instead of aborting execution.
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.
exactly.
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.
Now private functions are skipped, however i left this abortion, to indicate that something going wrong if we try to export private function.
Signed-off-by: Shanin Roman <[email protected]>
Signed-off-by: Shanin Roman <[email protected]>
Signed-off-by: Shanin Roman <[email protected]>
Signed-off-by: Shanin Roman <[email protected]>
Signed-off-by: Shanin Roman <[email protected]>
Signed-off-by: Shanin Roman <[email protected]>
f157ec0
to
e1a667e
Compare
Signed-off-by: Shanin Roman <[email protected]>
e1a667e
to
8877b81
Compare
Signed-off-by: Shanin Roman <[email protected]>
Signed-off-by: Shanin Roman <[email protected]>
8877b81
to
250134c
Compare
Description of the Change
Type__Trait__method
)Issue
Closes #2488.
Benefits
No need to manually implement trait methods.
Possible Drawbacks
None.
Usage Examples or Tests [optional]
Alternate Designs [optional]