rust-lang/rust · error · syn::Error
no attributes expected
Error message
no attributes expected
What it means
Thrown by the `#[base_name_enum]` attribute macro (enums.rs:110) when any attribute argument is provided. Unlike `function_enum`, this macro takes no arguments because it derives its variants from the global operation list.
Source
Thrown at library/compiler-builtins/crates/libm-macros/src/enums.rs:110
match self {
#( #base_arms, )*
}
}
}
};
Ok(res)
}
/// Implement `#[base_name_enum]`, see documentation in `lib.rs`.
pub fn base_name_enum(
mut item: ItemEnum,
attributes: pm2::TokenStream,
) -> syn::Result<pm2::TokenStream> {
expect_empty_enum(&item)?;
if !attributes.is_empty() {
let sp = attributes.span();
return Err(syn::Error::new(sp.span(), "no attributes expected"));
}
let mut base_names: Vec<_> = ALL_OPERATIONS
.iter()
.map(|func| base_name(func.name))
.collect();
base_names.sort_unstable();
base_names.dedup();
let item_name = &item.ident;
let mut as_str_arms = Vec::new();
for base_name in base_names {
let ident = Ident::new(&base_name.to_upper_camel_case(), Span::call_site());
// Match arm for `fn as_str(self)` matcher
as_str_arms.push(quote! { Self::#ident => #base_name });
View on GitHub (pinned to 7088e4b63a)
Solutions
- Use `#[base_name_enum]` with empty parentheses (or none).
- Remember: base_name_enum takes no attributes; function_enum takes one.
Example fix
// before
#[base_name_enum(Some)]
enum Bn {}
// after
#[base_name_enum]
enum Bn {} Defensive patterns
Strategy: validation
Prevention
- base_name_enum accepts zero attributes.
- Do not confuse it with function_enum, which requires one.
When it happens
Trigger: Writing `#[base_name_enum(SomeArg)]` or any form with tokens between the parentheses.
Common situations: Confusing `base_name_enum` with `function_enum` (which does take an argument); copy-pasting an attribute shape from the other macro.
Related errors
- expected one attribute
- expected an identifier
- unexpected token after identifier
- expected an empty enum
- unrecognized function name `{mentioned}`
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/590801661536703c.
Report an issue: GitHub.