{"record":{"id":"b0191c7ec4ebfdb7","repo":"swc-project/swc","slug":"unknown-span-attribute","errorCode":null,"errorMessage":"Unknown span attribute","messagePattern":"Unknown span attribute","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ast_node/src/spanned.rs","lineNumber":71,"sourceCode":"            }\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)\n        .variants()\n        .into_iter()\n        .map(|v| {\n            let (pat, bindings) = v.bind(\"_\", Some(Token![ref](def_site())), None);","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/ast_node/src/spanned.rs#L53-L89","documentation":"Compile-time panic from the Spanned derive support code (crates/ast_node/src/spanned.rs). A `#[span]` attribute must be either a bare path (`#[span]`) or a parenthesized list (`#[span(lo)]`/`#[span(hi)]`); the Meta::NameValue form (e.g. `#[span = \"lo\"]`) falls into the catch-all arm and panics with the argument-less message.","triggerScenarios":"Writing `#[span = \"lo\"]` or any `key = value` form of the span attribute on a field of a Spanned-deriving type.","commonSituations":"Editors auto-completing attributes into name-value syntax; converting attribute styles during refactors.","solutions":["Change the name-value form to list form: `#[span(lo)]` or `#[span(hi)]`","Use bare `#[span]` if the whole field is the span source"],"exampleFix":"// before\n#[span = \"lo\"]\npub start: Ident,\n\n// after\n#[span(lo)]\npub start: Ident,","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write span attributes as bare `#[span]` or list `#[span(lo)]`; never `#[span = \"...\"]`","Beware editors converting attributes to name-value form"],"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"}