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

Support multiple attribute occurrences #265

Closed
wants to merge 1 commit into from
Closed

Support multiple attribute occurrences #265

wants to merge 1 commit into from

Conversation

zohnannor
Copy link
Contributor

Synopsis

It is impossible to feature-gate additional type conversions in From, Into derive macros. Code such as:

#[derive(From)]
#[from(types(u8, u16))]
#[cfg_attr(feature = "myfeature", from(types(u32)))]
struct MyIntExplicit(u64);

will fail to compile with Only a single attribute is allowed when myfeature is enabled.

Solution

Instead of err-ing on second occurrence of the attribute when building MetaInfo, just proceed and collect all additional attributes into it. Anyway user will see the error message if they'll try to provide types to attributes, expansions of which will result in conflicting implementations.

As I understand the inner working of the macro, that's all there is to it to support multiple attributes?

Checklist

  • Documentation is updated (if required)
  • Tests are added/updated (if required)
  • CHANGELOG entry is added (if required)

@zohnannor
Copy link
Contributor Author

zohnannor commented Jun 21, 2023

Seems like this error will be fixed in #241, #248 PRs. I'll test if those resolve this issue.

@tyranron
Copy link
Collaborator

@zohnannor seems to be resolved in the latest beta releases. Feel free to reopen if something more is required.

@tyranron tyranron closed this Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants