{"record":{"id":"18d60a8600ee0b0c","repo":"swc-project/swc","slug":"stringenum-requires-all-variants-not-to-have-field","errorCode":null,"errorMessage":"StringEnum requires all variants not to have fields","messagePattern":"StringEnum requires all variants not to have fields","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/string_enum/src/lib.rs","lineNumber":165,"sourceCode":"                            attrs: Default::default(),\n                            lit: Lit::Str(item.alias),\n                        }));\n                    }\n\n                    pat = Pat::Or(PatOr {\n                        attrs: Default::default(),\n                        leading_vert: None,\n                        cases,\n                    });\n                    continue;\n                }\n\n                panic!(\"Unsupported meta: {:#?}\", attr.meta);\n            }\n\n            let body = match *v.data() {\n                Fields::Unit => Box::new(parse_quote!(return Ok(#qual_name))),\n                _ => unreachable!(\"StringEnum requires all variants not to have fields\"),\n            };\n\n            Arm {\n                body,\n                attrs: v\n                    .attrs()\n                    .iter()\n                    .filter(|attr| is_attr_name(attr, \"cfg\"))\n                    .cloned()\n                    .collect(),\n                pat,\n                guard: None,\n                fat_arrow_token: Default::default(),\n                comma: Some(Token![,](def_site())),\n            }\n        })\n        .chain(::std::iter::once(parse_quote!(_ => Err(()))))\n        .collect();","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/string_enum/src/lib.rs#L147-L183","documentation":"Raised in make_from_str during derive(StringEnum) (string_enum lib.rs:165). While processing each variant's attributes, the derive accepts only specific meta forms (the string tag and alias lists); any other attribute meta reached in the loop triggers 'Unsupported meta' and then this panic about variants requiring no fields. It fires when a variant carries data (non-unit variant) or an unrecognized attribute, either of which the string-enum codegen cannot handle. The variant's field list / stray attribute meta is the input at fault.","triggerScenarios":"Thrown at crates/string_enum/src/lib.rs:165 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make every variant of the StringEnum enum a unit variant (encode the string via the tag and aliases instead)","Remove unsupported attributes from variants; only the documented tag/alias metas are accepted","Report the unsupported meta with its span so the user can locate the bad attribute"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}