{"record":{"id":"bcc209e99a35b38a","repo":"yewstack/yew","slug":"only-structs-are-supported","errorCode":null,"errorMessage":"only structs are supported","messagePattern":"only structs are supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/yew-macro/src/derive_props/mod.rs","lineNumber":135,"sourceCode":"impl Parse for DerivePropsInput {\n    fn parse(input: ParseStream) -> Result<Self> {\n        let input: DeriveInput = input.parse()?;\n        let prop_fields = match input.data {\n            syn::Data::Struct(data) => match data.fields {\n                syn::Fields::Named(fields) => {\n                    let mut prop_fields: Vec<PropField> = fields\n                        .named\n                        .into_iter()\n                        .map(|f| f.try_into())\n                        .collect::<Result<Vec<PropField>>>()?;\n\n                    // Alphabetize\n                    prop_fields.sort();\n\n                    prop_fields\n                }\n                syn::Fields::Unit => Vec::new(),\n                _ => unimplemented!(\"only structs are supported\"),\n            },\n            _ => unimplemented!(\"only structs are supported\"),\n        };\n\n        let preserved_attrs = input\n            .attrs\n            .iter()\n            .filter(|a| should_preserve_attr(a))\n            .cloned()\n            .collect();\n\n        Ok(Self {\n            vis: input.vis,\n            props_name: input.ident,\n            generics: input.generics,\n            prop_fields,\n            preserved_attrs,\n        })","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/yewstack/yew/blob/0e4a05472fac4e5fce1befe60fa4a1e43a36b6a3/packages/yew-macro/src/derive_props/mod.rs#L117-L153","documentation":"Thrown by Yew's `#[derive(Properties)]` when it is applied to a struct whose fields are positional (a tuple struct). The derive generates a builder with one setter per named prop, so `syn::Fields::Unnamed` gives it no field names to work with and the `_` arm at derive_props/mod.rs:135 calls `unimplemented!`. Because it is a panic rather than a `syn::Error`, rustc reports 'proc macro panicked' with this message.","triggerScenarios":"Writing `#[derive(Clone, PartialEq, Properties)] struct Wrapper(String);` — any `Properties` derive on a tuple struct reaches this arm. Named-field structs and unit structs (`struct Foo;`) are accepted; only positional fields hit the panic.","commonSituations":"Wrapping a primitive or external type as component props (`struct ApiToken(String)`), translating prop examples from frameworks where positional payloads are common, or annotating generated tuple-struct code with the derive list.","solutions":["Convert the struct to named fields — the only field shape the derive supports: `struct Wrapper { token: String }`","If the newtype must stay positional for your API, keep it private and add a separate named-field props struct for the component, constructed from the newtype","As a last resort, implement `Properties` manually and provide the required `type Builder` plus its `Builder` impl yourself"],"exampleFix":"// before\n#[derive(Clone, PartialEq, Properties)]\nstruct Wrapper(String);\n\n// after\n#[derive(Clone, PartialEq, Properties)]\nstruct Wrapper {\n    token: String,\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use `#[derive(Properties)]` only on structs with named fields; tuple structs, enums, and unions are unsupported","Keep the props struct in the same module as its component so shape mistakes surface on the first `cargo check`","If you need a newtype in the public API, put it inside a named field of the props struct instead of making the props a tuple struct"],"tags":["rust","yew","proc-macro","derive","properties","tuple-struct","panic"],"backgroundTag":"derive-macro-unsupported-item","analyzedSha":"0e4a05472fac4e5fce1befe60fa4a1e43a36b6a3","analyzedAt":"2026-08-22T21:16:31.212Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}