rust-lang/rust · error · syn::Error
unrecognized type identifier `{ty_name}`
Error message
unrecognized type identifier `{ty_name}` What it means
The `for_each_function!` macro's `emit_types` field selects which type metadata to pass to the callback. Only identifiers in KNOWN_TYPES (CFn, CArgs, CRet, RustFn, RustArgs, RustRet, path) or the keyword `all` are accepted (lib.rs:13-15). During validate(), each entry is checked against that set; an entry matching none triggers this error.
Source
Thrown at library/compiler-builtins/crates/libm-macros/src/lib.rs:268
continue;
}
// Run everything else
fn_list.push(func);
}
// Types that the user would like us to provide in the macro
let mut add_all_types = false;
for ty in &input.emit_types {
let ty_name = ty.to_string();
if ty_name == "all" {
add_all_types = true;
continue;
}
// Check that all requested types are valid
if !KNOWN_TYPES.contains(&ty_name.as_str()) {
let e = syn::Error::new(
ty_name.span(),
format!("unrecognized type identifier `{ty_name}`"),
);
return Err(e);
}
}
if add_all_types {
// Ensure that if `all` was specified that nothing else was
if input.emit_types.len() > 1 {
let e = syn::Error::new(
input.emit_types_span.unwrap(),
"if `all` is specified, no other type identifiers may be given",
);
return Err(e);
}
// ...and then add all typesView on GitHub (pinned to 7088e4b63a)
Solutions
- Replace the invalid identifier with one of CFn, CArgs, CRet, RustFn, RustArgs, RustRet, or path.
- If every type is needed, use emit_types: all instead of listing names.
- Cross-check the spelling against the KNOWN_TYPES list in lib.rs:13.
Example fix
// before
libm_macros::for_each_function! {
callback: cb,
emit_types: [RustSignature],
}
// after
libm_macros::for_each_function! {
callback: cb,
emit_types: [RustFn, RustArgs, RustRet],
} Defensive patterns
Strategy: validation
Prevention
- Keep the allowed set (CFn, CArgs, CRet, RustFn, RustArgs, RustRet, path, all) visible when editing emit_types.
- Run a cargo check after any change to a for_each_function! invocation.
When it happens
Trigger: Supplying `emit_types: [RustSig]`, `emit_types: [FooType]`, or any list containing an identifier not in {CFn, CArgs, CRet, RustFn, RustArgs, RustRet, path, all}.
Common situations: Typoing a known type name (e.g. `RustFnction`), inventing a type identifier that does not exist, or migrating from an older version of the macro that used different names.
Related errors
- if `all` is specified, no other type identifiers may be give
- `fn_extra`: no default `_` pattern specified and the followi
- unrecognized meta expression `{s}`
- unexpected fields {map:?}
- `fn_extra` expects a match expression
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/7f6ba3fb572290ec.
Report an issue: GitHub.