{"record":{"id":"2a0d8f0ad5edc479","repo":"rust-lang/rust","slug":"key-key-specified-twice","errorCode":null,"errorMessage":"key `{key}` specified twice","messagePattern":"key `(.+?)` specified twice","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"library/compiler-builtins/crates/libm-macros/src/parse.rs","lineNumber":205,"sourceCode":"            comma: _,\n        } = arm;\n\n        expect_empty_attrs(&attrs)?;\n\n        let keys = match pat {\n            syn::Pat::Wild(w) => vec![Ident::new(\"_\", w.span())],\n            _ => Parser::parse2(parse_ident_pat, pat.into_token_stream())?,\n        };\n\n        if let Some(guard) = guard {\n            let e = syn::Error::new(guard.0.span(), \"no guards allowed in this position\");\n            return Err(e);\n        }\n\n        for key in keys {\n            let inserted = res.insert(key.clone(), *body.clone());\n            if inserted.is_some() {\n                let e = syn::Error::new(key.span(), format!(\"key `{key}` specified twice\"));\n                return Err(e);\n            }\n        }\n    }\n\n    Ok(res)\n}\n\nfn expect_empty_attrs(attrs: &[Attribute]) -> syn::Result<()> {\n    if attrs.is_empty() {\n        return Ok(());\n    }\n\n    let e = syn::Error::new(\n        attrs.first().unwrap().span(),\n        \"no attributes allowed in this position\",\n    );\n    Err(e)","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/library/compiler-builtins/crates/libm-macros/src/parse.rs#L187-L223","documentation":"Each function name (or the `_` default) may appear in only one fn_extra arm. extract_fn_extra_field() inserts keys into a BTreeMap and rejects a second insertion of the same key (parse.rs:202-208). Overlap can arise from `|` alternatives, duplicate arms, or from ALL_* group matchers expanding to functions also named explicitly.","triggerScenarios":"`fn_extra: match MACRO_FN_NAME { sin | sin => ... }`, two arms both listing `sin`, or using `ALL_F64` alongside an explicit arm for a function that ALL_F64 expands to (validate() expands group matchers, lib.rs:143-172).","commonSituations":"Adding an explicit arm for a function already covered by an ALL_F64/ALL_F32 group; duplicate alternatives via `|`.","solutions":["Remove the duplicate key so each function name appears in exactly one arm.","If using ALL_* group matchers, ensure no explicit arm repeats a function contained in that group."],"exampleFix":"// before\nfn_extra: match MACRO_FN_NAME {\n    ALL_F64 => |x| x,\n    sqrt => |x| x.sqrt(),\n    _ => |x| x,\n},\n// after\nfn_extra: match MACRO_FN_NAME {\n    sqrt => |x| x.sqrt(),\n    ALL_F64 => |x| x,\n    _ => |x| x,\n},  // note: remove sqrt from the ALL_F64 intent or drop the explicit arm","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Before adding an explicit arm, check it is not already covered by an ALL_* group.","Avoid listing the same name twice in `|` alternatives."],"tags":["rust","proc-macro","libm","compile-time","validation"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}