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

Derive should throw an error when applying field attributes to variants #150

Open
Manishearth opened this issue May 3, 2023 · 0 comments

Comments

@Manishearth
Copy link
Member

See #149

It's easy to accidentally write code like this:

#[derive(Arbitrary)]
enum Foo {
   A(u8),
   #[arbitrary(with = |_| Bar::new())]
   B(Bar).
}

Here, the attribute will not have any effect since it needs to be on the field, not the variant.

We should definitely error if a field attribute is found on a variant. We could optionally make the above case (where the variant has a single field) transparently work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant