{"record":{"id":"b2384ff214e3b2cc","repo":"astral-sh/ruff","slug":"prefix-has-already-been-defined-before","errorCode":null,"errorMessage":"prefix has already been defined before","messagePattern":"prefix has already been defined before","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/ruff_macros/src/rule_namespace.rs","lineNumber":71,"sourceCode":"                        return Err(Error::new(\n                            lit.span(),\n                            \"expected prefix string to be non-empty\",\n                        ));\n                    }\n                    Some(c) => {\n                        if !first_chars.insert(c) {\n                            return Err(Error::new(\n                                lit.span(),\n                                format!(\n                                    \"this variant already has another prefix \\\n                                    starting with the character '{c}'\"\n                                ),\n                            ));\n                        }\n                    }\n                }\n                if !all_prefixes.insert(str.clone()) {\n                    return Err(Error::new(\n                        lit.span(),\n                        \"prefix has already been defined before\",\n                    ));\n                }\n                Ok(str)\n            })\n            .collect();\n        let prefixes = prefixes?;\n\n        if prefixes.is_empty() {\n            return Err(Error::new(\n                variant.span(),\n                r#\"Missing #[prefix = \"...\"] attribute\"#,\n            ));\n        }\n\n        let Some(doc_attr) = variant\n            .attrs","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_macros/src/rule_namespace.rs#L53-L89","documentation":"Compile-time error from the rule_namespace derive in ruff_macros. While collecting the string-literal prefixes attached to enum variants, derive_impl inserts each prefix's first character into a set; if the character is already present, two variants declare prefixes that begin with the same character, making prefix-based rule-code dispatch ambiguous. The macro rejects the expansion with this error at the offending literal's span. Not a runtime condition — fix by making each variant's prefix start with a distinct character.","triggerScenarios":"Thrown at crates/ruff_macros/src/rule_namespace.rs:71 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the duplicate prefix declaration","Rename one of the prefixes to a unique string"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}