{"record":{"id":"8f903157f4bfaabb","repo":"rust-lang/rust","slug":"expected-one-attribute","errorCode":null,"errorMessage":"expected one attribute","messagePattern":"expected one attribute","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"library/compiler-builtins/crates/libm-macros/src/enums.rs","lineNumber":21,"sourceCode":"use proc_macro2::{Ident, Span};\nuse quote::quote;\nuse syn::spanned::Spanned;\nuse syn::{Fields, ItemEnum, Variant};\n\nuse crate::{ALL_OPERATIONS, base_name};\n\n/// Implement `#[function_enum]`, see documentation in `lib.rs`.\npub fn function_enum(\n    mut item: ItemEnum,\n    attributes: pm2::TokenStream,\n) -> syn::Result<pm2::TokenStream> {\n    expect_empty_enum(&item)?;\n    let attr_span = attributes.span();\n    let mut attr = attributes.into_iter();\n\n    // Attribute should be the identifier of the `BaseName` enum.\n    let Some(tt) = attr.next() else {\n        return Err(syn::Error::new(attr_span, \"expected one attribute\"));\n    };\n\n    let pm2::TokenTree::Ident(base_enum) = tt else {\n        return Err(syn::Error::new(tt.span(), \"expected an identifier\"));\n    };\n\n    if let Some(tt) = attr.next() {\n        return Err(syn::Error::new(\n            tt.span(),\n            \"unexpected token after identifier\",\n        ));\n    }\n\n    let enum_name = &item.ident;\n    let mut as_str_arms = Vec::new();\n    let mut from_str_arms = Vec::new();\n    let mut base_arms = Vec::new();\n","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/library/compiler-builtins/crates/libm-macros/src/enums.rs#L3-L39","documentation":"Thrown by the `#[function_enum]` attribute macro (enums.rs:21) when it is invoked with no attribute argument. The macro requires exactly one attribute — the identifier of the companion `BaseName` enum — so an empty attribute list is rejected.","triggerScenarios":"Writing `#[function_enum]` or `#[function_enum()]` on an enum without providing the `BaseName` enum identifier as the attribute.","commonSituations":"Copy-pasting the macro from docs and dropping the attribute; renaming the macro invocation while refactoring.","solutions":["Add the BaseName enum identifier as the single attribute: `#[function_enum(BaseName)]`.","Ensure the named enum is itself annotated with `#[base_name_enum]`."],"exampleFix":"// before\n#[function_enum]\nenum Func {}\n\n// after\n#[function_enum(BaseName)]\nenum Func {}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["function_enum always requires exactly one identifier attribute naming the BaseName enum.","Keep the attribute and the BaseName enum definition consistent."],"tags":["proc-macro","libm","function-enum","validation"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}