{"record":{"id":"189f83f216dfb139","repo":"bevyengine/bevy","slug":"the-key-attribute-is-not-supported-for-structs-w","errorCode":null,"errorMessage":"The `key` attribute is not supported for structs with named fields","messagePattern":"The `key` attribute is not supported for structs with named fields","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/macros/src/lib.rs","lineNumber":707,"sourceCode":"                    } else if meta.path.is_ident(\"file\") {\n                        let value = meta.value()?;\n                        let s: syn::LitStr = value.parse()?;\n                        override_file = Some(s.value());\n                        Ok(())\n                    } else {\n                        Err(meta.error(\"unsupported attribute\"))\n                    }\n                })\n                .ok()\n            });\n\n        (override_group_name, override_key_name, override_file)\n    };\n\n    let key_name = match &input.data {\n        Data::Struct(data) => match data.fields {\n            Fields::Named(_) if override_key_name.is_some() => {\n                return syn::Error::new(\n                    Span::call_site(),\n                    \"The `key` attribute is not supported for structs with named fields\",\n                )\n                .into_compile_error()\n                .into();\n            }\n            Fields::Named(_) => None,\n            Fields::Unnamed(_) | Fields::Unit => {\n                override_key_name.or_else(|| Some(pascal_to_snake_case(&name.to_string())))\n            }\n        },\n        Data::Enum(_) => override_key_name.or(Some(pascal_to_snake_case(&name.to_string()))),\n        Data::Union(_) => {\n            return syn::Error::new(\n                Span::call_site(),\n                \"SettingsGroup cannot be derived for unions\",\n            )\n            .into_compile_error()","sourceCodeStart":689,"sourceCodeEnd":725,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/macros/src/lib.rs#L689-L725","documentation":"Compile error from derive_settings_group: the input is a struct with named fields (where each field already defines its own sub-key) but an explicit `key = \"...\"` override attribute was also supplied. The key attribute only applies to tuple/unit structs, so this guard rejects the combination.","triggerScenarios":"Thrown at crates/bevy_ecs/macros/src/lib.rs:707 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the #[key = \"...\")] attribute and let named fields supply their own keys","Convert the struct to a tuple or unit struct if a single key override is needed","Apply key overrides at the field/group level where supported"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}