diesel-rs/diesel · error · syn::Error
, the correct format is `#[variadic(3)]
Error message
{e}, the correct format is `#[variadic(3)]` What it means
Error from the `#[sql_function]` macro when the variadic attribute is used in its old path form: diesel expected the attribute to be a bare path/identifier (i.e. `#[variadic(3)]` with just an integer), but `require_ident` found something else (e.g. an unexpected path segment or key). The message appends the correct positional format.
Solutions
- Use the positional form exactly: `#[variadic(3)]` with a single integer literal
- Or switch to the keyword form: `#[variadic(last_arguments = 3)]`
- Upgrade/check diesel docs to confirm which variadic syntax your version supports
Example fix
// before #[variadic(some::path)] // after #[variadic(3)]
Defensive patterns
Strategy: validation
Validate before calling
fn validate_variadic_positional(inner: &str) -> Result<(), String> {
let t = inner.trim();
if t.parse::<u32>().is_ok() { Ok(()) } else { Err(format!("positional variadic must be a bare integer: #[variadic(3)], got {}", t)) }
} Prevention
- Use a single integer literal for the positional form: #[variadic(3)]
- Prefer the keyword form `last_arguments = N` which has clearer errors
- Don't mix old and new syntaxes within one attribute
When it happens
Trigger: Using `#[sql_function]` with a legacy-style `#[variadic(...)]` attribute where the content is not a plain identifier path as expected by `path.require_ident()` — e.g. `#[variadic(foo::bar)]` misparsed or a malformed path.
Common situations: Mixing the old positional syntax `#[variadic(3)]` with the newer keyword syntax in one attribute; copying examples from different diesel versions.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- expected attribute `name` help: the correct format looks…
- unknown attribute, expected
- expect `skip_zero_argument_variant`
- , the correct format is `#[variadic(last_arguments = 3)]`…
- unexpected option
AI-assisted analysis of diesel-rs/diesel@6fa6ed01b2 (2026-09-07).
Data as JSON: /api/errors/315f618ae56e6cd1.
Report an issue: GitHub.
Appendix: source
Thrown at diesel_derives/src/sql_function.rs:1453
LitBool::new(false, Span::call_site())
};
Ok((count, skip_zero))
}
})
.map_err(|e| {
syn::Error::new(
e.span(),
format!(
"{e}, the correct format is `#[variadic(last_arguments = 3)]` or `#[variadic(last_arguments = 3, skip_zero_argument_variant = true)]`"
),
)
})?;
Ok(AttributeSpanWrapper {
item: SqlFunctionAttribute::Variadic {
ident: path
.require_ident()
.map_err(|e| {
syn::Error::new(
e.span(),
format!("{e}, the correct format is `#[variadic(3)]`"),
)
})?
.clone(),
count: count.clone(),
skip_zero_arg_variant: flag,
},
attribute_span: attr.span(),
ident_span: path.require_ident()?.span(),
})
}
syn::Meta::NameValue(_) | syn::Meta::Path(_) => Ok(AttributeSpanWrapper {
attribute_span: attr.span(),
ident_span: attr.span(),
item: SqlFunctionAttribute::Other(attr),
}),
syn::Meta::List(_) => {View on GitHub (pinned to 6fa6ed01b2)