rust-lang/rust · error · syn::Error
`fn_extra`: no default `_` pattern specified and the followi
Error message
`fn_extra`: no default `_` pattern specified and the following patterns are not covered: {fns_not_covered:#?} What it means
The `fn_extra` field maps each function to a per-invocation expression via a `match MACRO_FN_NAME { ... }`. If no `_ =>` default arm is supplied, validate() requires every function in the expansion set to have an explicit arm (lib.rs:294-316); otherwise expansion would unwrap a missing map entry. The error lists the uncovered functions.
Source
Thrown at library/compiler-builtins/crates/libm-macros/src/lib.rs:307
let ident = Ident::new(ty, Span::call_site());
input.emit_types.push(ident);
}
}
if let Some(map) = &input.fn_extra
&& !map.keys().any(|key| key == "_")
{
// No default provided; make sure every expected function is covered
let mut fns_not_covered = Vec::new();
for func in &fn_list {
if !map.keys().any(|key| key == func.name) {
// `name` was not mentioned in the `match` statement
fns_not_covered.push(func);
}
}
if !fns_not_covered.is_empty() {
let e = syn::Error::new(
input.fn_extra_span.unwrap(),
format!(
"`fn_extra`: no default `_` pattern specified and the following \
patterns are not covered: {fns_not_covered:#?}"
),
);
return Err(e);
}
};
Ok(fn_list)
}
/// Expand our structured macro input into invocations of the callback macro.
fn expand(input: StructuredInput, fn_list: &[&MathOpInfo]) -> syn::Result<pm2::TokenStream> {
let mut out = pm2::TokenStream::new();
let default_ident = Ident::new("_", Span::call_site());
let callback = input.callback;View on GitHub (pinned to 7088e4b63a)
Solutions
- Add a `_ => <expr>` default arm to the fn_extra match.
- Add explicit arms for every function named in the error's fns_not_covered list.
- Narrow the expansion with skip/only so only the functions you have arms for are emitted.
Example fix
// before
fn_extra: match MACRO_FN_NAME {
sin => |x| x.sin(),
},
// after
fn_extra: match MACRO_FN_NAME {
sin => |x| x.sin(),
_ => |x| x,
}, Defensive patterns
Strategy: validation
Prevention
- Always include a `_ =>` default arm unless you intentionally enumerate every function.
- When changing skip/only, re-check that fn_extra arms still cover the expansion set.
When it happens
Trigger: Providing `fn_extra: match MACRO_FN_NAME { sin => ... }` with no `_ =>` arm while the macro expands for functions beyond `sin` (i.e. they are not all skipped or excluded via only).
Common situations: Editing skip/only so the expanded function set changes and the explicit arms no longer cover it; forgetting the default arm; renaming a function.
Related errors
- unrecognized type identifier `{ty_name}`
- if `all` is specified, no other type identifiers may be give
- 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/109185259b80688c.
Report an issue: GitHub.