swc-project/swc · error
failed to parse meta
Error message
failed to parse meta
What it means
`#[parallel]` (swc_ecma_transforms_macros) accepts either an empty argument list or one syn `Meta` value, whose only recognized form is the path `explode`. When the attribute is non-empty, it is parsed with `syn::parse2::<Meta>` and this `expect("failed to parse meta")` panics at compile time if the tokens are not a valid Meta (path, `name = value`, or parenthesized list).
Source
Thrown at crates/swc_ecma_transforms_macros/src/parallel.rs:22
use syn::{parse_quote, Expr, Ident, ImplItem, ImplItemFn, ItemImpl, Meta, Type};
use crate::common::Mode;
pub fn expand(attr: TokenStream, mut item: ItemImpl) -> ItemImpl {
let mode = {
let p = &item.trait_.as_ref().unwrap().1;
if p.is_ident("Fold") {
Mode::Fold
} else if p.is_ident("VisitMut") {
Mode::VisitMut
} else {
unimplemented!("Unknown visitor type: {:?}", p)
}
};
let meta = if attr.is_empty() {
None
} else {
Some(syn::parse2::<Meta>(attr).expect("failed to parse meta"))
};
let explode = meta
.as_ref()
.map(|v| v.path().is_ident("explode"))
.unwrap_or(false);
item.items.push(ImplItem::Fn(make_par_visit_method(
mode,
"module_items",
explode,
)));
item.items
.push(ImplItem::Fn(make_par_visit_method(mode, "stmts", explode)));
item
}
fn node_type(suffix: &str) -> Type {View on GitHub (pinned to 5176682b65)
Solutions
- Use the bare form: `#[parallel]` for default behavior, `#[parallel(explode)]` to also emit the explode-style visit method.
- Remove configuration objects, strings, and assignments from the attribute; it takes no key-value config.
- Make sure the annotated item is an `impl Fold` or `impl VisitMut` block, not another trait.
Example fix
// before
#[parallel(explode = true)]
impl VisitMut for MyPass { /* ... */ }
// after
#[parallel(explode)]
impl VisitMut for MyPass { /* ... */ } Defensive patterns
Strategy: validation
Prevention
- Use only `#[parallel]` or `#[parallel(explode)]` — the macro accepts no other form.
- Do not attempt to pass config structs or key=value options; there is none.
- Ensure the annotated block is an impl of Fold or VisitMut; other traits are rejected (unimplemented!).
When it happens
Trigger: Writing `#[parallel(ParallelConfig { .. })]`, `#[parallel(explode =)]` (missing value), `#[parallel("explode")]` (string literal), or any expression-style tokens instead of a bare path. Note `#[parallel(explode)]` is the intended usage; the macro only checks `path().is_ident("explode")`.
Common situations: Contributors enabling parallel visitor processing on a `Fold`/`VisitMut` impl for a transform that should not recurse into child scopes, who try to pass a config struct or a key-value pair instead of the bare `explode` flag. Also note the macro only supports impls of exactly `Fold` or `VisitMut` (an adjacent `unimplemented!` fires otherwise).
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Unknown visitor type: {:?}
- Usage should be like #[fast_path(ArrowVisitor)]
- 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
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/7b76b3be9c7049a9.
Report an issue: GitHub.