{"record":{"id":"34b124a1356155d1","repo":"bevyengine/bevy","slug":"entityevent-derive-does-not-work-on-unit-structs","errorCode":null,"errorMessage":"EntityEvent derive does not work on unit structs. Your type must have a field to store the `Entity` target, such as `Attack(Entity)` or `Attack { entity: Entity }`.","messagePattern":"EntityEvent derive does not work on unit structs\\. Your type must have a field to store the `Entity` target, such as `Attack\\(Entity\\)` or `Attack (.+?)`\\.","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/macros/src/event.rs","lineNumber":204,"sourceCode":"            fields.span(),\n            \"EntityEvent derive expected a field name 'entity' or a field annotated with #[event_target].\"\n        )),\n        Fields::Unnamed(fields) if fields.unnamed.len() == 1 => Ok(Member::Unnamed(Index::from(0))),\n        Fields::Unnamed(fields) => fields.unnamed.iter().enumerate().find_map(|(index, field)| {\n                if field\n                    .attrs\n                    .iter()\n                    .any(|attr| attr.path().is_ident(EVENT_TARGET)) {\n                        Some(Member::Unnamed(Index::from(index)))\n                    } else {\n                        None\n                    }\n            })\n            .ok_or(syn::Error::new(\n                fields.span(),\n                \"EntityEvent derive expected unnamed structs with one field or with a field annotated with #[event_target].\",\n            )),\n        Fields::Unit => Err(syn::Error::new(\n            fields.span(),\n            \"EntityEvent derive does not work on unit structs. Your type must have a field to store the `Entity` target, such as `Attack(Entity)` or `Attack { entity: Entity }`.\",\n        )),\n    }\n}\n","sourceCodeStart":186,"sourceCodeEnd":210,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/macros/src/event.rs#L186-L210","documentation":"Compile error from get_event_target_field: the struct is a unit struct with zero fields, so there is nowhere to store the Entity target required by EntityEvent. This is the final match arm guarding Fields::Unit, with a hint message suggesting field shapes that work.","triggerScenarios":"Thrown at crates/bevy_ecs/macros/src/event.rs:204 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a field to store the target, e.g. struct Attack(Entity); or struct Attack { entity: Entity }","Use a marker component separately instead of deriving EntityEvent on a unit struct"],"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-14T05:17:10.506Z"}