{"record":{"id":"d1296f5cd732d2d8","repo":"swc-project/swc","slug":"usage-should-be-like-fast-path-arrowvisitor","errorCode":null,"errorMessage":"Usage should be like #[fast_path(ArrowVisitor)]","messagePattern":"Usage should be like #\\[fast_path\\(ArrowVisitor\\)\\]","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_transforms_macros/src/fast.rs","lineNumber":10,"sourceCode":"use proc_macro2::TokenStream;\nuse quote::quote;\nuse swc_macros_common::call_site;\nuse syn::{parse_quote, FnArg, Ident, ImplItem, ImplItemFn, ItemImpl, Pat, Path};\n\nuse crate::common::Mode;\n\npub fn expand(attr: TokenStream, item: ItemImpl) -> ItemImpl {\n    let expander = Expander {\n        handler: syn::parse2(attr).expect(\"Usage should be like #[fast_path(ArrowVisitor)]\"),\n        mode: detect_mode(&item),\n    };\n    let items = expander.inject_default_methods(item.items);\n\n    ItemImpl {\n        items: items\n            .into_iter()\n            .map(|item| match item {\n                ImplItem::Fn(m) => ImplItem::Fn(expander.patch_method(m)),\n                _ => item,\n            })\n            .collect(),\n        ..item\n    }\n}\n\nfn detect_mode(i: &ItemImpl) -> Mode {\n    if i.items.iter().any(|item| match item {","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_transforms_macros/src/fast.rs#L1-L28","documentation":"`#[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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n#[fast_path(\"ArrowVisitor\")]\nimpl VisitMut for ArrowPass { /* ... */ }\n\n// after\n#[fast_path(ArrowVisitor)]\nimpl VisitMut for ArrowPass { /* ... */ }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["proc-macro","attribute-argument","fast-path","compile-time","swc"],"backgroundTag":"macro-attribute-argument-invalid","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}