diesel-rs/diesel · error

expected `disable`, but got

Error message

expected `disable`, but got `{ident}`

What it means

Compile-time error from parsing the #[diesel(disable_...)] style check used for per-backend attribute disabling. The Parse impl for DisabledCheckForBackend reads one identifier and requires it to be exactly `disable`; a different word after the relevant attribute keyword (e.g. `disabled` or `off`) triggers this error, which includes the offending identifier. Fix: write the flag as `disable`.

Solutions

  1. Write `disable` as the first token inside the attribute
  2. Remove the attribute if backend checks should stay enabled
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at diesel_attribute_parser/src/lib.rs:456 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/6925de52f94bd6c5. Report an issue: GitHub.

Appendix: source

Thrown at diesel_attribute_parser/src/lib.rs:456

                        item: value,
                        attribute_span: attr.meta.span(),
                    });
                }
            }
        }
    }
    Ok(out)
}

struct DisabledCheckForBackend {
    value: LitBool,
}

impl syn::parse::Parse for DisabledCheckForBackend {
    fn parse(input: ParseStream) -> Result<Self> {
        let ident = input.parse::<Ident>()?;
        if ident != "disable" {
            return Err(syn::Error::new(
                ident.span(),
                format!("expected `disable`, but got `{ident}`"),
            ));
        }
        let lit = parse_eq::<LitBool>(input, "")?;
        if !lit.value {
            return Err(syn::Error::new(
                lit.span(),
                "only `true` is accepted in this position. \
                 If you want to enable these checks, just skip the attribute entirely",
            ));
        }
        Ok(Self { value: lit })
    }
}

#[derive(Debug, Clone, Copy)]
#[allow(clippy::enum_variant_names)]

View on GitHub (pinned to 6fa6ed01b2)