arbitrary icon indicating copy to clipboard operation
arbitrary copied to clipboard

Derive should throw an error when applying field attributes to variants

Open Manishearth opened this issue 1 year ago • 0 comments

See https://github.com/rust-fuzz/arbitrary/issues/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.

Manishearth avatar May 03 '23 01:05 Manishearth