{"record":{"id":"fadfba762c422a0a","repo":"rust-lang/rust","slug":"missing-expected-field-name","errorCode":null,"errorMessage":"missing expected field `{name}`","messagePattern":"missing expected field `(.+?)`","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"library/compiler-builtins/crates/libm-macros/src/parse.rs","lineNumber":229,"sourceCode":"    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)\n}\n\n/// Extract a named field from a map, raising an error if it doesn't exist.\nfn expect_field(v: &mut Vec<Mapping>, name: &str) -> syn::Result<Expr> {\n    let pos = v.iter().position(|v| v.name == name).ok_or_else(|| {\n        syn::Error::new(\n            Span::call_site(),\n            format!(\"missing expected field `{name}`\"),\n        )\n    })?;\n\n    Ok(v.remove(pos).expr)\n}\n\n/// Coerce an expression into a simple identifier.\nfn expect_ident(expr: Expr) -> syn::Result<Ident> {\n    syn::parse2(expr.into_token_stream())\n}\n\n/// Coerce an expression into a simple keyword.\nfn expect_litbool(expr: Expr) -> syn::Result<LitBool> {\n    syn::parse2(expr.into_token_stream())\n}\n","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/library/compiler-builtins/crates/libm-macros/src/parse.rs#L211-L247","documentation":"The only mandatory top-level field of for_each_function! is `callback`, the name of the macro to invoke once per function (parse.rs:76, 226-236). expect_field() returns this error (via `?`) when `callback` is absent; all other fields are optional (.ok()).","triggerScenarios":"Omitting `callback: ...` from the invocation entirely.","commonSituations":"Starting to write a macro invocation and forgetting the callback macro reference; deleting the line accidentally.","solutions":["Add a `callback: your_macro_name` field to the invocation."],"exampleFix":"// before\nlibm_macros::for_each_function! {\n    emit_types: all,\n}\n// after\nlibm_macros::for_each_function! {\n    callback: my_callback,\n    emit_types: all,\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Every for_each_function! block must start with a callback: field.","Use a snippet/template that already includes the callback line."],"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-14T00:17:10.932Z"}