swc-project/swc · error · syn::Error
unknown ast_node option
Error message
unknown ast_node option
What it means
The #[ast_node] attribute macro's Args parser accepts only the `no_partial_eq` option after the type; any other identifier makes the proc macro return this syn::Error at the option's span, failing compilation of the annotated item.
Source
Thrown at crates/ast_node/src/ast_node_macro.rs:24
#[derive(Clone)]
pub struct Args {
pub ty: Literal,
pub no_partial_eq: bool,
}
impl Parse for Args {
fn parse(i: ParseStream<'_>) -> syn::Result<Self> {
let ty = i.parse()?;
let mut no_partial_eq = false;
if i.parse::<Option<Token![,]>>()?.is_some() {
let option: Ident = i.parse()?;
if option == "no_partial_eq" {
no_partial_eq = true;
} else {
return Err(Error::new(option.span(), "unknown ast_node option"));
}
}
if !i.is_empty() {
return Err(i.error("unexpected ast_node arguments"));
}
Ok(Args { ty, no_partial_eq })
}
}
pub fn expand_struct(args: Args, i: DeriveInput) -> Vec<ItemImpl> {
let mut items = Vec::new();
let generics = i.generics.clone();
// let item_ident = Ident::new("Item", i.ident.span());
{
let ty = &i.ident;View on GitHub (pinned to 5176682b65)
Solutions
- Use only the supported `no_partial_eq` option in the #[ast_node] invocation
- Fix the typo in the attribute name
- Extend Args::parse if a genuinely new option is required
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/ast_node/src/ast_node_macro.rs:24 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/d325cbb2fd43d65d.
Report an issue: GitHub.