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

unexpected end of input, expected parentheses

Error message

unexpected end of input, expected parentheses

What it means

The deprecated `treat_none_as_null` attribute parser requires parenthesized arguments; the attribute was given with empty or missing parentheses, so the parser reports `unexpected end of input, expected parentheses`.

Solutions

  1. Add a boolean argument: `#[diesel(treat_none_as_null(true))]` or `(false)`
  2. Remove the attribute entirely if you want the default behavior (None maps to a skipped column, not SQL NULL)

Example fix

// before
#[diesel(treat_none_as_null)]
pub struct NewPost { title: Option<String> }
// after
#[diesel(treat_none_as_null(true))]
pub struct NewPost { title: Option<String> }
Defensive patterns

Strategy: validation

Validate before calling

// compile-time check: attribute must be #[diesel(treat_none_as_null(true|false))]

Prevention

When it happens

Trigger: Writing `#[diesel(treat_none_as_null)]` without `(true)` or `(false)` on an `Insertable`/`AsChangeset` struct.

Common situations: Copying the attribute name from docs without the value, or removing the value while debugging NULL-handling behavior.

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

Appendix: source

Thrown at diesel_attribute_parser/src/deprecated/changeset_options.rs:9

use syn::parse::{ParseStream, Result};
use syn::{Ident, LitBool, parenthesized};

use crate::deprecated::utils::parse_eq_and_lit_str;
use crate::notes::TREAT_NONE_AS_NULL_NOTE;

pub fn parse_changeset_options(name: Ident, input: ParseStream) -> Result<(Ident, LitBool)> {
    if input.is_empty() {
        return Err(syn::Error::new(
            name.span(),
            "unexpected end of input, expected parentheses",
        ));
    }

    let content;
    parenthesized!(content in input);

    let name: Ident = content.parse()?;
    let name_str = name.to_string();

    if name_str != "treat_none_as_null" {
        return Err(syn::Error::new(
            name.span(),
            "expected `treat_none_as_null`",
        ));
    }

View on GitHub (pinned to 6fa6ed01b2)