astral-sh/ruff · error · syn::Error
this variant already has another prefix starting with the ch
Error message
this variant already has another prefix starting with the character '{c}' What it means
A syn compile error from the RuleNamespace derive: two #[prefix] attributes on the same variant start with the same character. Rule codes are dispatched by first character, so duplicate leading characters within a variant would be ambiguous.
Source
Thrown at crates/ruff_macros/src/rule_namespace.rs:60
..
}) = &attr.meta
else {
return Err(Error::new(
attr.span(),
r#"expected attribute to be in the form of [#prefix = "..."]"#,
));
};
let str = lit.value();
match str.chars().next() {
None => {
return Err(Error::new(
lit.span(),
"expected prefix string to be non-empty",
));
}
Some(c) => {
if !first_chars.insert(c) {
return Err(Error::new(
lit.span(),
format!(
"this variant already has another prefix \
starting with the character '{c}'"
),
));
}
}
}
if !all_prefixes.insert(str.clone()) {
return Err(Error::new(
lit.span(),
"prefix has already been defined before",
));
}
Ok(str)
})
.collect();View on GitHub (pinned to 26f38c119c)
Solutions
- Give the variant prefixes distinct first characters
- Remove one of the conflicting prefixes
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/ruff_macros/src/rule_namespace.rs:60 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/6b7877c710a73079.
Report an issue: GitHub.