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

, the correct format is `#[window]

Error message

{e}, the correct format is `#[window]`

What it means

Compile-time error when processing the #[sql_function] attribute list. In the Window attribute variant, the inner attribute is required to be a bare identifier; require_ident() fails on any other meta form (e.g. `#[window(...)]` with arguments), and the original syn error is wrapped with a hint stating the correct usage `#[window]`. Fix: write the flag without arguments as `#[window]`.

Solutions

  1. Use `#[window]` with no arguments
  2. Move any options to a supported location

Example fix

// before
#[sql_function]
#[window(partition_by = true)]
fn row_number() -> BigInt;

// after
#[sql_function]
#[window]
fn row_number() -> BigInt;
Defensive patterns

Strategy: validation

Validate before calling

// Attribute must be a bare path: #[window]
let attr_src = "#[window]";
assert!(attr_src == "#[window]"); // no args, no assignment

Prevention

When it happens

Trigger: Writing `#[window(...)]`, `#[window = true]`, or a qualified path like `#[foo::window]` inside a `#[sql_function(...)]` attribute.

Common situations: Assuming window function configuration (partition/order) belongs in the attribute; copying other frameworks' attribute syntax.

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


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

Appendix: source

Thrown at diesel_derives/src/sql_function.rs:1393

                        .require_ident()
                        .map_err(|e| {
                            syn::Error::new(
                                e.span(),
                                format!("{e}, the correct format is `#[skip_return_type_helper]`"),
                            )
                        })?
                        .clone(),
                },
            })
        }
        syn::Meta::Path(path) if path.is_ident("window") => Ok(AttributeSpanWrapper {
            attribute_span: attr.span(),
            ident_span: path.span(),
            item: SqlFunctionAttribute::Window {
                ident: path
                    .require_ident()
                    .map_err(|e| {
                        syn::Error::new(e.span(), format!("{e}, the correct format is `#[window]`"))
                    })?
                    .clone(),
                restrictions: BackendRestriction::None,
                require_order: None,
                wrap_macro: None,
            },
        }),
        syn::Meta::List(syn::MetaList {
            path,
            delimiter: syn::MacroDelimiter::Paren(_),
            tokens: _,
        }) if path.is_ident("variadic") => {
            let (count, flag) = attr
                .parse_args_with(|input: syn::parse::ParseStream| {
                    if input.peek(LitInt){
                        let count = input.parse::<LitInt>()?;
                        if !input.is_empty(){
                            return Err(syn::Error::new(input.span(), "unexpected token after positional `#[variadic(..)]`"));

View on GitHub (pinned to 6fa6ed01b2)