diesel-rs/diesel · error
unexpected end of input, expected `=` help: the correct…
Error message
unexpected end of input, expected `=`
help: the correct format looks like `#[diesel({help})]` What it means
Raised by the `parse_eq` helper when the attribute's token stream is empty where a `key = value` pair was expected. The parser anticipated a `=` assignment but hit the end of input instead, so it reports the expected shape with a help line.
Solutions
- Provide the value after the key: `key = value`
- Fill in the placeholder from the help text with a concrete value
- Remove the dangling key if it was not intended
Example fix
// before #[diesel(sqlite_type(name))] // after #[diesel(sqlite_type(name = "text"))]
Defensive patterns
Strategy: validation
Validate before calling
// Ensure every diesel attribute key is followed by `= value`
for pair in attr.parse_args_with<Punctuated<Meta, Token![,]>>()? {
assert!(matches!(pair, Meta::NameValue(_)), "key must have `= value`");
} Prevention
- Never write a bare key inside #[diesel(...)] — every key needs `= value`
- Fill in placeholder values immediately when copying examples
- Format code (rustfmt) to spot incomplete attributes
When it happens
Trigger: Writing `#[diesel(sqlite_type(name))]` (key without `=` and value), or an attribute like `#[diesel(...)]` where the parser expects `key = value` but finds nothing left to parse.
Common situations: Omitting the `= value` part after an attribute key; forgetting to fill in a value when copying an example.
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.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- unexpected end of input, expected parentheses help: the…
- unexpected token after positional `#[variadic(..)]`
- expect `last_arguments`
- expected attribute `name` help: the correct format looks…
- unknown attribute, expected
AI-assisted analysis of diesel-rs/diesel@6fa6ed01b2 (2026-09-07).
Data as JSON: /api/errors/5783b6d0cab1da72.
Report an issue: GitHub.
Appendix: source
Thrown at diesel_attribute_parser/src/util.rs:19
use syn::parse::{Parse, ParseStream, Peek, Result};
use syn::token::Eq;
use syn::{Ident, Type, parenthesized};
pub fn unknown_attribute(name: &Ident, valid: &[&str]) -> syn::Error {
let prefix = if valid.len() == 1 { "" } else { " one of" };
syn::Error::new(
name.span(),
format!(
"unknown attribute, expected{prefix} `{}`",
valid.join("`, `")
),
)
}
pub fn parse_eq<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 `=`\n\
help: the correct format looks like `#[diesel({help})]`",
),
));
}
input.parse::<Eq>()?;
input.parse()
}
/// Specialized version of `parse_eq` for `syn::Type` with a customized error message for readability.
/// This is useful because a great variety of tokens would be valid to parse as a `syn::Type`.
pub fn parse_eq_type(input: ParseStream, help: &str) -> Result<syn::Type> {
if input.is_empty() {
return Err(syn::Error::new(
input.span(),View on GitHub (pinned to 6fa6ed01b2)