{"record":{"id":"c31663e3bd83b9c4","repo":"rust-lang/rust","slug":"expected-an-empty-enum","errorCode":null,"errorMessage":"expected an empty enum","messagePattern":"expected an empty enum","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"library/compiler-builtins/crates/libm-macros/src/enums.rs","lineNumber":159,"sourceCode":"        #item\n\n        impl #item_name {\n            /// The stringified version of this base name.\n            pub const fn as_str(self) -> &'static str {\n                match self {\n                    #( #as_str_arms ),*\n                }\n            }\n        }\n    };\n\n    Ok(res)\n}\n\n/// Verify that an enum is empty, otherwise return an error\nfn expect_empty_enum(item: &ItemEnum) -> syn::Result<()> {\n    if !item.variants.is_empty() {\n        Err(syn::Error::new(\n            item.variants.span(),\n            \"expected an empty enum\",\n        ))\n    } else {\n        Ok(())\n    }\n}\n","sourceCodeStart":141,"sourceCodeEnd":167,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/library/compiler-builtins/crates/libm-macros/src/enums.rs#L141-L167","documentation":"Thrown by `expect_empty_enum` (enums.rs:159), called by both `#[function_enum]` and `#[base_name_enum]`, when the annotated enum already has variants. Both macros populate the enum themselves from the global operation list, so the source enum must be empty.","triggerScenarios":"Annotating an enum that already declares variants, e.g. `enum Func { Foo, Bar }`.","commonSituations":"Adding a placeholder variant during development; merging an existing enum under the macro; misunderstanding that the macro generates the variants.","solutions":["Declare the enum with no variants: `enum Func {}`.","Remove any manually-added variants; the macro generates them."],"exampleFix":"// before\n#[function_enum(BaseName)]\nenum Func {\n    Foo,\n}\n\n// after\n#[function_enum(BaseName)]\nenum Func {}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Both function_enum and base_name_enum require an empty enum; variants are generated.","Never hand-write variants into a macro-annotated enum."],"tags":["proc-macro","libm","enum","validation"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}