{"record":{"id":"5e0e25f3538b05c4","repo":"swc-project/swc","slug":"unknown-span-attribute-kind","errorCode":null,"errorMessage":"Unknown span attribute: {kind:?}","messagePattern":"Unknown span attribute: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ast_node/src/spanned.rs","lineNumber":67,"sourceCode":"\n        for attr in &f.attrs {\n            if !is_attr_name(attr, \"span\") {\n                continue;\n            }\n\n            match &attr.meta {\n                Meta::Path(..) => {}\n                Meta::List(list) => {\n                    let input = parse2::<InputFieldAttr>(list.tokens.clone())\n                        .expect(\"failed to parse as `InputFieldAttr`\");\n\n                    for kind in input.kinds {\n                        if kind == \"lo\" {\n                            lo = true\n                        } else if kind == \"hi\" {\n                            hi = true\n                        } else {\n                            panic!(\"Unknown span attribute: {kind:?}\")\n                        }\n                    }\n                }\n                _ => panic!(\"Unknown span attribute\"),\n            }\n        }\n\n        Self {\n            ident: f.ident.clone(),\n            ty: f.ty.clone(),\n            lo,\n            hi,\n        }\n    }\n}\n\npub fn derive(input: DeriveInput) -> ItemImpl {\n    let arms = Binder::new_from(&input)","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/ast_node/src/spanned.rs#L49-L85","documentation":"Compile-time panic from the Spanned derive support code (crates/ast_node/src/spanned.rs). Inside a `#[span(...)]` field attribute, the macro parses a comma-separated ident list (`InputFieldAttr`) and only `lo` and `hi` are valid kinds; any other ident panics with `Unknown span attribute: {kind:?}`.","triggerScenarios":"Writing `#[span(low)]`, `#[span(lho)]`, or `#[span(lo, whole)]` on a field of a type deriving Spanned.","commonSituations":"Typos in span markers while porting AST node definitions; assuming extra span kinds (e.g. `both`, `full`) exist because `lo`/`hi` do.","solutions":["Correct the attribute to exactly `#[span(lo)]` or `#[span(hi)]`","Mark one field `#[span(lo)]` and another `#[span(hi)]` to compose a span from both ends"],"exampleFix":"// before\nstruct Bin {\n    #[span(low)]\n    pub left: Expr,\n}\n\n// after\nstruct Bin {\n    #[span(lo)]\n    pub left: Expr,\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only `lo` and `hi` inside `#[span(...)]`","Pair each `#[span(lo)]` with a `#[span(hi)]` on another field from the start"],"tags":["rust","proc-macro","swc","span","derive","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-14T00:17:10.932Z"}