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

(more) Syn 2.0 updates #3738

Closed
wants to merge 11 commits into from
Closed

(more) Syn 2.0 updates #3738

wants to merge 11 commits into from

Conversation

DCNick3
Copy link
Contributor

@DCNick3 DCNick3 commented Jul 24, 2023

Description

NOTE: This PR is based on #3727, so only last 3 commits are actually belong to this PR

This PR refactors iroha_primitives_derive crate and VariantCount macro in iroha_derive. The gist of the changes: use manyhow to report errors and darling to parse attributes. Try to improve UX where possible.

I've kept API the same for all the macros, but it may be useful to change some of them:

  • confusingly, attributes for VariantCount are placed on fields instead of enum variants. I suggest we move them to variants, as it's really a property of the variant
  • the naming of #[skip_try_from] is confusing in the context of #[skip_from]: the different in names is in the try, but they correspond to different directions of the generated conversions: from is for Variant -> Enum and try_from is for Enum -> Variant. I suggest changing the name to #[skip_into] or #[skip_try_into] to properly represent the change of conversion direction, even if the actual generated trait is From
  • Maybe change #[skip_container] to #[skip_from_container]?

I would like some input on this from other team members though ^^

Checklist

…s to our proc macros

Signed-off-by: Nikita Strygin <DCNick3@users.noreply.github.com>
…proc-macro-error with manyhow

Signed-off-by: Nikita Strygin <DCNick3@users.noreply.github.com>
…e`. It does it pretty well =)

Signed-off-by: Nikita Strygin <DCNick3@users.noreply.github.com>
Not crates-io version, because there is a problem with the 0.5.0 release =(

Signed-off-by: Nikita Strygin <DCNick3@users.noreply.github.com>
Signed-off-by: Nikita Strygin <DCNick3@users.noreply.github.com>
n -> version
versioned -> versioned_alias

Signed-off-by: Nikita Strygin <DCNick3@users.noreply.github.com>
Signed-off-by: Nikita Strygin <DCNick3@users.noreply.github.com>
Signed-off-by: Nikita Strygin <DCNick3@users.noreply.github.com>
Signed-off-by: Nikita Strygin <DCNick3@users.noreply.github.com>
It's just strum::EnumCount anyways

Signed-off-by: Nikita Strygin <DCNick3@users.noreply.github.com>
- use darling's traits to parse the input
- cover attributes with tests
- add a diagnostic for a common error: attribute on variant instead of field
- ensure spans for generated enums are linked to enum variants, which improves "conflicting implementation" errors

Signed-off-by: Nikita Strygin <DCNick3@users.noreply.github.com>
@github-actions github-actions bot added the iroha2-dev The re-implementation of a BFT hyperledger in RUST label Jul 24, 2023
@DCNick3 DCNick3 self-assigned this Jul 25, 2023
@DCNick3 DCNick3 changed the title Syn2 updates (more) Syn 2.0 updates Jul 26, 2023
@DCNick3
Copy link
Contributor Author

DCNick3 commented Jul 26, 2023

The changes are now part of #3727

@DCNick3 DCNick3 closed this Jul 26, 2023
@DCNick3 DCNick3 deleted the syn2-updates branch July 28, 2023 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iroha2-dev The re-implementation of a BFT hyperledger in RUST
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant