diesel-rs/diesel · error

unexpected end of input, expected parentheses help: the…

Error message

unexpected end of input, expected parentheses
help: the correct format looks like `#[diesel({help})]`

What it means

Compile-time error from the shared attribute-parser helper parse_paren, which parses a parenthesized `key = value` group (e.g. #[diesel(sql_type = "...")]). It is a generic guard for malformed attribute input: it fires when the token stream ends before any parenthesized content is found, i.e. the attribute was written without its `(...)` arguments. Fix: supply the parenthesized arguments in the documented format.

Solutions

  1. Add the required parentheses and their contents
  2. Follow the attribute format shown in the help text

Example fix

// before
#[diesel(foreign_key)]
// after
#[diesel(foreign_key(other_table.some_column))]
Defensive patterns

Strategy: validation

Validate before calling

let src = quote::quote! { #attr }.to_string();
assert!(src.contains('('), "diesel attribute key requires parenthesized arguments");

Prevention

When it happens

Trigger: Writing `#[diesel(foreign_key)]` or similar keys that require `(...)` content but leaving the parentheses empty/absent at the point of parse.

Common situations: Forgetting the parenthesized arguments for attributes like `foreign_key = ...` or `sqlite_type(...)`; deleting the contents during a refactor.

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/f3d3564344df0845. Report an issue: GitHub.

Appendix: source

Thrown at diesel_attribute_parser/src/util.rs:53

    if input.is_empty() {
        return Err(syn::Error::new(
            input.span(),
            format!(
                "unexpected end of input, expected `=`\n\
                 help: the correct format looks like `#[diesel({help})]`",
            ),
        ));
    }

    input.parse::<Eq>()?;
    input
        .parse::<Type>()
        .map_err(|e| syn::Error::new(e.span(), "expected type"))
}

pub fn parse_paren<T: Parse>(input: ParseStream, help: &str) -> Result<T> {
    if input.is_empty() {
        return Err(syn::Error::new(
            input.span(),
            format!(
                "unexpected end of input, expected parentheses\n\
                 help: the correct format looks like `#[diesel({help})]`",
            ),
        ));
    }

    let content;
    parenthesized!(content in input);
    content.parse()
}

pub fn parse_paren_list<T, D>(
    input: ParseStream,
    help: &str,
    sep: D,
) -> Result<syn::punctuated::Punctuated<T, <D as Peek>::Token>>

View on GitHub (pinned to 6fa6ed01b2)