{"record":{"id":"2edb926e84993929","repo":"bevyengine/bevy","slug":"derive-derive-expected-unnamed-structs-with-one","errorCode":null,"errorMessage":"{derive} derive expected unnamed structs with one field or with a field annotated with #[relationship].","messagePattern":"(.+?) derive expected unnamed structs with one field or with a field annotated with #\\[relationship\\]\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/macro_logic/src/component.rs","lineNumber":817,"sourceCode":"    match fields {\n        Fields::Named(fields) if fields.named.len() == 1 => Ok(fields.named.first().unwrap()),\n        Fields::Named(fields) => fields.named.iter().find(|field| {\n            field\n                .attrs\n                .iter()\n                .any(|attr| attr.path().is_ident(RELATIONSHIP))\n        }).ok_or(syn::Error::new(\n            span,\n            format!(\"{derive} derive expected named structs with a single field or with a field annotated with #[relationship].\")\n        )),\n        Fields::Unnamed(fields) if fields.unnamed.len() == 1 => Ok(fields.unnamed.first().unwrap()),\n        Fields::Unnamed(fields) => fields.unnamed.iter().find(|field| {\n                field\n                    .attrs\n                    .iter()\n                    .any(|attr| attr.path().is_ident(RELATIONSHIP))\n            })\n            .ok_or(syn::Error::new(\n                span,\n                format!(\"{derive} derive expected unnamed structs with one field or with a field annotated with #[relationship].\"),\n            )),\n        Fields::Unit => Err(syn::Error::new(\n            span,\n            format!(\"{derive} derive expected named or unnamed struct, found unit struct.\"),\n        )),\n    }\n}\n","sourceCodeStart":799,"sourceCodeEnd":827,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/macro_logic/src/component.rs#L799-L827","documentation":"Compile error from relationship_field: the derive was applied to a tuple (unnamed) struct with multiple fields and none is marked #[relationship], so the helper cannot pick the relationship field. This branch mirrors the named-struct guard for Fields::Unnamed.","triggerScenarios":"Thrown at crates/bevy_ecs/macro_logic/src/component.rs:817 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Mark the intended field with #[relationship]: struct X(#[relationship] Entity, Foo);","Shrink the tuple struct to a single field such as struct ChildOf(Entity);","Use a named struct with one field instead"],"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"}