rust-fuzz / rust-fuzz/arbitrary

Derive should throw an error when applying field attributes to variants

Open
#150 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Rust
Stars
880
Forks
93
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name implementation files or tests, so first locate the derive handling for field attributes on enum variants. Reproduce the shown enum case and verify that applying a field-only attribute to a variant produces an error rather than being silently ignored.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.