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

Unknown case: , expected one of: `PascalCase`…

Error message

Unknown case: {other}, expected one of: `PascalCase`, `snake_case`, `UpperCamelCase`, `lowerCamelCase`, `SHOUTY_SNAKE_CASE`, `dO_nOt_cHaNgE_cAsE`

What it means

Compile-time error from dsl_auto_type's Case::from_str, which converts the case-convention string in #[dsl_auto_type(...)] (the auto_type case option) into a Case enum. The string must be exactly one of the six supported names; any other value (typically a typo) is rejected. Note the supported set differs from diesel's rename_all set (e.g. it has lowerCamelCase/UpperCamelCase, not camelCase/PascalCase variants of those names). Fix: use one of the listed case strings.

Solutions

  1. Use one of the supported names such as `PascalCase`, `snake_case`, or `SHOUTY_SNAKE_CASE`
  2. Check the exact casing and spelling of the chosen case name
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at dsl_auto_type/src/auto_type/case.rs:38 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at dsl_auto_type/src/auto_type/case.rs:38

            Case::LowerCamel => s.to_lower_camel_case(),
            Case::Snake => s.to_snake_case(),
            Case::ShoutySnake => s.to_shouty_snake_case(),
        };
        Ident::new(&cased_s, ident.span())
    }
}

impl Case {
    pub(crate) fn from_str(s: &str, span: Span) -> Result<Self, syn::Error> {
        Ok(match s {
            "dO_nOt_cHaNgE_cAsE" => Case::DoNotChange,
            "UpperCamelCase" => Case::UpperCamel,
            "PascalCase" => Case::Pascal,
            "lowerCamelCase" => Case::LowerCamel,
            "snake_case" => Case::Snake,
            "SHOUTY_SNAKE_CASE" => Case::ShoutySnake,
            other => {
                return Err(syn::Error::new(
                    span,
                    format_args!(
                        "Unknown case: {other}, expected one of: \
                            `PascalCase`, `snake_case`, `UpperCamelCase`, `lowerCamelCase`, \
                            `SHOUTY_SNAKE_CASE`, `dO_nOt_cHaNgE_cAsE`"
                    ),
                ));
            }
        })
    }
}

View on GitHub (pinned to 6fa6ed01b2)