block/buzz · error · syn::Error

duplicate `fields` argument

Error message

duplicate `fields` argument

What it means

The third duplicate-guard in #[datastore_span]'s Parse impl: `fields` is optional and parenthesized (fields(...)), and may appear only once; a second occurrence is rejected at the duplicate key's span with 'duplicate `fields` argument'. Note fields takes a parenthesized expression list, not `fields = ...` — using '=' after fields is a separate syntax error from syn.

Source

Thrown at crates/buzz-datastore-tracing/src/lib.rs:42

            let key: Ident = input.parse()?;
            match key.to_string().as_str() {
                "name" => {
                    if name.is_some() {
                        return Err(Error::new(key.span(), "duplicate `name` argument"));
                    }
                    input.parse::<Token![=]>()?;
                    name = Some(input.parse()?);
                }
                "system" => {
                    if system.is_some() {
                        return Err(Error::new(key.span(), "duplicate `system` argument"));
                    }
                    input.parse::<Token![=]>()?;
                    system = Some(input.parse()?);
                }
                "fields" => {
                    if fields.is_some() {
                        return Err(Error::new(key.span(), "duplicate `fields` argument"));
                    }
                    let content;
                    parenthesized!(content in input);
                    fields = Some(content.parse()?);
                }
                _ => {
                    return Err(Error::new(
                        key.span(),
                        "expected `name`, `system`, or `fields`",
                    ))
                }
            }
            if !input.is_empty() {
                input.parse::<Token![,]>()?;
            }
        }

        Ok(Self {

View on GitHub (pinned to eed74bde2f)

Solutions

  1. Merge both parenthesized field lists into a single fields(...) — comma-separate the tracing field expressions inside one group.
  2. Drop fields entirely if none of the extra fields are needed (it is optional).
  3. Verify with `cargo check -p <crate>`.

Example fix

// before
#[datastore_span(name = "q", system = "postgresql", fields(a = 1), fields(b = 2))]

// after
#[datastore_span(name = "q", system = "postgresql", fields(a = 1, b = 2))]
Defensive patterns

Strategy: validation

Validate before calling

// compile-time only: `cargo check` points at the second `fields(...)` span

Prevention

When it happens

Trigger: #[datastore_span(name = "q", system = "postgresql", fields(db.operation), fields(x))] at crates/buzz-datastore-tracing/src/lib.rs:40-42 — the second fields(...) group is rejected during macro expansion.

Common situations: Merging two annotated functions' extras fields lists instead of concatenating the contents; copy-paste adding a second fields(...) instead of editing the first; forgetting the argument is optional and 're-declaring' it.

Related errors


AI-assisted analysis of block/buzz@eed74bde2f (2026-08-20). Data as JSON: /api/errors/08b4fbed9cb8ee89. Report an issue: GitHub.