swc-project/swc · error
Usage should be like #[fast_path(ArrowVisitor)]
Error message
Usage should be like #[fast_path(ArrowVisitor)]
What it means
`#[fast_path]` is applied to an `impl` of `Fold` or `VisitMut` (swc_ecma_transforms_macros). `expand` parses the attribute argument with `syn::parse2` to obtain the visitor type path (e.g. `ArrowVisitor`). The `expect("Usage should be like #[fast_path(ArrowVisitor)]")` panics at compile time when the parenthesized argument is not a single valid syn path.
Source
Thrown at crates/swc_ecma_transforms_macros/src/fast.rs:10
use proc_macro2::TokenStream;
use quote::quote;
use swc_macros_common::call_site;
use syn::{parse_quote, FnArg, Ident, ImplItem, ImplItemFn, ItemImpl, Pat, Path};
use crate::common::Mode;
pub fn expand(attr: TokenStream, item: ItemImpl) -> ItemImpl {
let expander = Expander {
handler: syn::parse2(attr).expect("Usage should be like #[fast_path(ArrowVisitor)]"),
mode: detect_mode(&item),
};
let items = expander.inject_default_methods(item.items);
ItemImpl {
items: items
.into_iter()
.map(|item| match item {
ImplItem::Fn(m) => ImplItem::Fn(expander.patch_method(m)),
_ => item,
})
.collect(),
..item
}
}
fn detect_mode(i: &ItemImpl) -> Mode {
if i.items.iter().any(|item| match item {View on GitHub (pinned to 5176682b65)
Solutions
- Use exactly one path as the argument: `#[fast_path(ArrowVisitor)]`.
- Remove quotes, `=`, braces, or extra arguments from the attribute; configuration beyond the visitor name is not supported here.
- Define the named visitor type (e.g. `struct ArrowVisitor;`) in the same impl context the macro expects, so the generated code also compiles.
Example fix
// before
#[fast_path("ArrowVisitor")]
impl VisitMut for ArrowPass { /* ... */ }
// after
#[fast_path(ArrowVisitor)]
impl VisitMut for ArrowPass { /* ... */ } Defensive patterns
Strategy: validation
Prevention
- Write the attribute exactly as `#[fast_path(VisitorName)]` — one bare path, no quotes, no generics, no second argument.
- After editing macros, run `cargo check` on the transform crate; proc-macro panics point at the offending attribute.
- Copy an existing working usage (e.g. in swc_ecma_transforms arrow pass) as the canonical form.
When it happens
Trigger: Writing `#[fast_path]` with empty parens or no argument, passing a string `#[fast_path("ArrowVisitor")]`, a type with generics or multiple comma-separated items `#[fast_path(A, B)]`, or any token stream that is not one bare path.
Common situations: Contributors adding or modifying transforms in swc_ecma_transforms (e.g. es2015 arrow functions) who mis-type the attribute; refactors that rename the attribute or move configuration into it. The panic is emitted by rustc as a proc-macro panic pointing at the impl block.
Related errors
- method of Fold / VisitMut must accept two parameters
- failed to parse meta
- 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/d1296f5cd732d2d8.
Report an issue: GitHub.