{"record":{"id":"239db0dc9204072e","repo":"swc-project/swc","slug":"unknown-attribute-attr","errorCode":null,"errorMessage":"unknown attribute: {attr:?}","messagePattern":"unknown attribute: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ast_node/src/lib.rs","lineNumber":184,"sourceCode":"    // we should use call_site\n    let mut item = TokenStream::new();\n    match &input.data {\n        Data::Enum(data) => {\n            use syn::parse::Parser;\n\n            let attrs = <syn::punctuated::Punctuated<syn::Ident, syn::Token![,]>>::parse_terminated\n                .parse(args)\n                .expect(\"failed to parse #[ast_node]\");\n\n            let mut has_no_clone = false;\n            let mut has_no_unknown = false;\n            for attr in &attrs {\n                if attr == \"no_clone\" {\n                    has_no_clone = true;\n                } else if attr == \"no_unknown\" {\n                    has_no_unknown = true;\n                } else {\n                    panic!(\"unknown attribute: {attr:?}\")\n                }\n            }\n\n            let clone = if !has_no_clone {\n                Some(quote!(#[derive(Clone)]))\n            } else {\n                None\n            };\n            let non_exhaustive = if !has_no_unknown {\n                Some(quote!(#[cfg_attr(swc_ast_unknown, non_exhaustive)]))\n            } else {\n                None\n            };\n\n            let mut data = data.clone();\n            if !has_no_unknown {\n                let unknown: syn::Variant = if data\n                    .variants","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/ast_node/src/lib.rs#L166-L202","documentation":"Compile-time panic from the `#[ast_node]` proc-macro attribute. The attribute list is parsed as comma-separated idents and only two flags are recognized: `no_clone` (skip deriving Clone) and `no_unknown` (skip the `#[cfg_attr(swc_ast_unknown, non_exhaustive)]` emission). Any other ident panics with `unknown attribute`.","triggerScenarios":"Using `#[ast_node(no_visit)]`, `#[ast_node(clone)]`, or a typo like `#[ast_node(no_clne)]`; anything not exactly `no_clone` or `no_unknown` reaches the else arm.","commonSituations":"Assuming ast_node supports visitor or serde flags it does not; copying flag names from other SWC macros or older versions; IDE autocomplete suggesting nonexistent flags.","solutions":["Remove the unknown ident from the attribute list","Use exactly `no_clone` or `no_unknown` (or both, comma-separated)","Check the attribute parsing code in crates/ast_node/src/lib.rs and its tests for the currently accepted flag set"],"exampleFix":"// before\n#[ast_node(no_visit)]\npub struct Node { pub span: Span }\n\n// after\n#[ast_node(no_clone)]\npub struct Node { pub span: Span }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only pass `no_clone` and `no_unknown` to `#[ast_node]`","Grep your crate for `#[ast_node(` and review each flag before upgrading swc_ast_node","Let CI `cargo check` catch typos at expansion time"],"tags":["rust","proc-macro","swc","ast-node","compile-time"],"backgroundTag":"proc-macro-misuse","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}