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

  1. Use the bare form: `#[parallel]` for default behavior, `#[parallel(explode)]` to also emit the explode-style visit method.
  2. Remove configuration objects, strings, and assignments from the attribute; it takes no key-value config.
  3. 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

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

Related errors


AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17). Data as JSON: /api/errors/7b76b3be9c7049a9. Report an issue: GitHub.