diesel-rs/diesel · error · syn::Error

Expected `#[ ]` to have no arguments

Error message

Expected `#[{attribute_name}]` to have no arguments

What it means

Compile-time error from take_flag in diesel_table_macro_syntax, which parses flag attributes like #[table_name] or #[sqlite_name] that must appear as bare paths with no arguments. The guard fires when the flag attribute carries a value or list, e.g. #[macro_use = "..."] style forms, since flags only support the argument-free form. Fix: write the attribute without parentheses or `= value`.

Solutions

  1. Use the bare attribute path with no arguments
  2. Remove any `= ...` or parenthesized values
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at diesel_table_macro_syntax/src/lib.rs:258 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diesel-rs/diesel@6fa6ed01b2 (2026-09-07). Data as JSON: /api/errors/d3728f174f57851b. Report an issue: GitHub.

Appendix: source

Thrown at diesel_table_macro_syntax/src/lib.rs:258

    }
    Ok(None)
}

fn take_flag(
    meta: &mut Vec<syn::Attribute>,
    attribute_name: &'static str,
) -> Result<bool, syn::Error> {
    if let Some(index) = meta.iter().position(|m| {
        m.path()
            .get_ident()
            .map(|i| i == attribute_name)
            .unwrap_or(false)
    }) {
        let attribute = meta.remove(index);
        if matches!(attribute.meta, syn::Meta::Path(_)) {
            Ok(true)
        } else {
            Err(syn::Error::new(
                attribute.span(),
                format_args!("Expected `#[{attribute_name}]` to have no arguments"),
            ))
        }
    } else {
        Ok(false)
    }
}

View on GitHub (pinned to 6fa6ed01b2)