{"record":{"id":"12320d91354c58da","repo":"swc-project/swc","slug":"unknown-visitor-type","errorCode":null,"errorMessage":"Unknown visitor type: {:?}","messagePattern":"Unknown visitor type: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_transforms_macros/src/parallel.rs","lineNumber":16,"sourceCode":"#![allow(non_snake_case)]\n\nuse proc_macro2::{Span, TokenStream};\nuse syn::{parse_quote, Expr, Ident, ImplItem, ImplItemFn, ItemImpl, Meta, Type};\n\nuse crate::common::Mode;\n\npub fn expand(attr: TokenStream, mut item: ItemImpl) -> ItemImpl {\n    let mode = {\n        let p = &item.trait_.as_ref().unwrap().1;\n        if p.is_ident(\"Fold\") {\n            Mode::Fold\n        } else if p.is_ident(\"VisitMut\") {\n            Mode::VisitMut\n        } else {\n            unimplemented!(\"Unknown visitor type: {:?}\", p)\n        }\n    };\n    let meta = if attr.is_empty() {\n        None\n    } else {\n        Some(syn::parse2::<Meta>(attr).expect(\"failed to parse meta\"))\n    };\n    let explode = meta\n        .as_ref()\n        .map(|v| v.path().is_ident(\"explode\"))\n        .unwrap_or(false);\n\n    item.items.push(ImplItem::Fn(make_par_visit_method(\n        mode,\n        \"module_items\",\n        explode,\n    )));\n    item.items","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/swc-project/swc/blob/d7d74346665e36e692aa07e13d4ee3ee692ee35c/crates/swc_ecma_transforms_macros/src/parallel.rs#L1-L34","documentation":"`#[parallel]` generates parallel visit helpers by inspecting the implemented trait path: only `Fold` and `VisitMut` are recognized (`p.is_ident(\"Fold\")` / `VisitMut`); any other trait panics with `unimplemented!(\"Unknown visitor type: ...\")`. An inherent impl with no trait panics even earlier on `trait_.as_ref().unwrap()`.","triggerScenarios":"Apply `#[parallel]` to `impl MyTrait for X { ... }` or to an inherent `impl X { ... }` block.","commonSituations":"Attribute applied too broadly via copied boilerplate or editor macro expansion; refactoring a visitor impl into another trait without removing the attribute.","solutions":["Remove `#[parallel]` from impl blocks of traits other than Fold/VisitMut","Keep the attribute strictly on the visitor impl blocks it was designed for"],"exampleFix":"// before\n#[parallel]\nimpl MyPass for Visitor { ... }\n\n// after\nimpl MyPass for Visitor { ... }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Apply `#[parallel]` only to `impl Fold` / `impl VisitMut` blocks","When refactoring a visitor into another trait, delete the attribute in the same commit"],"tags":["macro","parallel","visitor","compile-time"],"backgroundTag":null,"analyzedSha":"d7d74346665e36e692aa07e13d4ee3ee692ee35c","analyzedAt":"2026-08-16T12:41:13.160Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}