{"record":{"id":"0073902cf5ee6afd","repo":"bevyengine/bevy","slug":"unnamed-fields-are-not-supported-here","errorCode":null,"errorMessage":"Unnamed fields are not supported here","messagePattern":"Unnamed fields are not supported here","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bevy_macro_utils/src/shape.rs","lineNumber":29,"sourceCode":"    match data {\n        Data::Struct(data_struct) => Ok(&data_struct.fields),\n        Data::Enum(DataEnum { enum_token, .. }) => Err(Error::new(\n            enum_token.span(),\n            format!(\"#[{meta}] only supports structs, not enums\"),\n        )),\n        Data::Union(DataUnion { union_token, .. }) => Err(Error::new(\n            union_token.span(),\n            format!(\"#[{meta}] only supports structs, not unions\"),\n        )),\n    }\n}\n\n/// Return an error if `Fields` is not `Fields::Named`\npub fn require_named<'a>(fields: &'a Fields) -> Result<&'a Punctuated<Field, Comma>, Error> {\n    if let Fields::Named(fields) = fields {\n        Ok(&fields.named)\n    } else {\n        Err(Error::new(\n            fields.span(),\n            \"Unnamed fields are not supported here\",\n        ))\n    }\n}\n","sourceCodeStart":11,"sourceCodeEnd":35,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_macro_utils/src/shape.rs#L11-L35","documentation":"Emitted by bevy_macro_utils::shape::require_named when a Bevy derive that requires named fields is applied to a tuple struct or unit struct. Currently used by the Specializer derive in bevy_render's macros, which generates code that accesses fields by name, so unnamed fields cannot be supported.","triggerScenarios":"Writing `#[derive(Specializer)] struct MySpec(u32);` or a unit struct `struct Marker;` — any Fields::Unnamed/Fields::Unit input reaches require_named and returns the error with a span over the parenthesized field list.","commonSituations":"Refactoring a Specializer struct from named fields to a tuple struct; writing a new specialization key type by mirroring a tuple-struct component elsewhere in the codebase.","solutions":["Give the struct named fields: `struct MySpec { value: u32 }`.","If the type is only a marker with no data, keep it a named-field struct with no fields or add a placeholder named field."],"exampleFix":"// before\n#[derive(Specializer)]\nstruct KeyDesc(u32, u32);\n\n// after\n#[derive(Specializer)]\nstruct KeyDesc {\n    key: u32,\n    base_instance: u32,\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give every Specializer-derived struct named fields.","When refactoring field names, keep the braces form: `struct S { field: T }` not `struct S(T)`.","Remember unit structs (`struct S;`) also fail this check — add at least one named field."],"tags":["rust","bevy","proc-macro","derive","compile-time","render"],"backgroundTag":"derive-macro-invalid-input","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T20:17:18.057Z"}