swc-project/swc · error
Unsupported meta: {:#?}
Error message
Unsupported meta: {:#?} What it means
Compile-time panic from `#[derive(StringEnum)]` (crates/string_enum). The optional per-variant `#[string_enum(...)]` attribute is only supported in list form — `#[string_enum(alias("foo"))]` adds extra FromStr match arms. If the attribute appears as a bare path (`#[string_enum]`) or name-value form, `attr.meta` is not `Meta::List` and the macro panics with `Unsupported meta: {:#?}`.
Source
Thrown at crates/string_enum/src/lib.rs:160
for item in parse2::<FieldAttr>(meta.tokens.clone())
.expect("failed to parse `#[string_enum]`")
.aliases
{
cases.push(Pat::Lit(PatLit {
attrs: Default::default(),
lit: Lit::Str(item.alias),
}));
}
pat = Pat::Or(PatOr {
attrs: Default::default(),
leading_vert: None,
cases,
});
continue;
}
panic!("Unsupported meta: {:#?}", attr.meta);
}
let body = match *v.data() {
Fields::Unit => Box::new(parse_quote!(return Ok(#qual_name))),
_ => unreachable!("StringEnum requires all variants not to have fields"),
};
Arm {
body,
attrs: v
.attrs()
.iter()
.filter(|attr| is_attr_name(attr, "cfg"))
.cloned()
.collect(),
pat,
guard: None,
fat_arrow_token: Default::default(),View on GitHub (pinned to 5176682b65)
Solutions
- Use the list form: `#[string_enum(alias("foo"))]`
- Remove the attribute entirely if no alias is needed
Example fix
// before
#[string_enum(alias = "commonjs")]
CommonJs,
// after
#[string_enum(alias("commonjs"))]
CommonJs, Defensive patterns
Strategy: validation
Prevention
- Write aliases only as `#[string_enum(alias("foo"))]` — list form, string literal argument
- Never use bare `#[string_enum]` or `alias = "..."` on variants
When it happens
Trigger: Writing `#[string_enum]` alone or `#[string_enum(alias = "foo")]` on a variant of a StringEnum-deriving enum.
Common situations: Trying to add alias support and guessing the syntax; attribute style drift after refactors.
Related errors
- StringEnum: Cannot determine string value of this variant
- An element descriptor's .kind property must be either "metho
- An element descriptor's .placement property must be one of "
- A class descriptor's .kind property must be "class", but a d
- ${objectType} can't have a .${name} property.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/1b0a19f8c820a38b.
Report an issue: GitHub.