astral-sh/ruff · error · syn::Error
unexpected suffix `{suffix}` on string literal
Error message
unexpected suffix `{suffix}` on string literal What it means
A syn compile error from get_string_literal in the option macros: a value passed to default/value_type/scope/example is a string literal with a suffix attached after the closing quote. The macros require plain string literals.
Source
Thrown at crates/ruff_macros/src/config.rs:343
fn get_string_literal(
meta: &ParseNestedMeta,
meta_name: &str,
attribute_name: &str,
) -> syn::Result<syn::LitStr> {
let expr: syn::Expr = meta.value()?.parse()?;
let mut value = &expr;
while let syn::Expr::Group(e) = value {
value = &e.expr;
}
if let syn::Expr::Lit(ExprLit {
lit: Lit::Str(lit), ..
}) = value
{
let suffix = lit.suffix();
if !suffix.is_empty() {
return Err(syn::Error::new(
lit.span(),
format!("unexpected suffix `{suffix}` on string literal"),
));
}
Ok(lit.clone())
} else {
Err(syn::Error::new(
expr.span(),
format!("expected {attribute_name} attribute to be a string: `{meta_name} = \"...\"`"),
))
}
}
#[derive(Default, Debug)]
struct DeprecatedAttribute {
since: Option<String>,
note: Option<String>,View on GitHub (pinned to 26f38c119c)
Solutions
- Remove the suffix so the value is a plain string literal
- Quote the whole value correctly, e.g. default = "true"
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/ruff_macros/src/config.rs:343 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of astral-sh/ruff@26f38c119c (2026-09-05).
Data as JSON: /api/errors/59332c71ac8e3e84.
Report an issue: GitHub.