rust-fuzz/arbitrary

Derive should throw an error when applying field attributes to variants

Manishearth opened this issue · 0 comments

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.