{"record":{"id":"b443ca63a8d74b89","repo":"bevyengine/bevy","slug":"deriving-deref-kind-on-multi-field-structs-requi","errorCode":null,"errorMessage":"deriving {deref_kind} on multi-field structs requires one field to have the {deref_attr_str} attribute","messagePattern":"deriving (.+?) on multi-field structs requires one field to have the (.+?) attribute","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_derive/src/derefs.rs","lineNumber":94,"sourceCode":"\n                    if selected_field.is_some() {\n                        return Err(syn::Error::new_spanned(\n                            attr,\n                            format!(\n                                \"{deref_attr_str} attribute can only be used on a single field\"\n                            ),\n                        ));\n                    }\n\n                    let member = to_member(field, index);\n                    selected_field = Some((member, &field.ty));\n                }\n            }\n\n            if let Some(selected_field) = selected_field {\n                Ok(selected_field)\n            } else {\n                Err(syn::Error::new(\n                    Span::call_site().into(),\n                    format!(\"deriving {deref_kind} on multi-field structs requires one field to have the {deref_attr_str} attribute\"),\n                ))\n            }\n        }\n        _ => Err(syn::Error::new(\n            Span::call_site().into(),\n            format!(\"{deref_kind} can only be derived on structs\"),\n        )),\n    }\n}\n\nfn to_member(field: &Field, index: usize) -> Member {\n    field\n        .ident\n        .as_ref()\n        .map(|name| Member::Named(name.clone()))\n        .unwrap_or_else(|| Member::Unnamed(Index::from(index)))","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_derive/src/derefs.rs#L76-L112","documentation":"Compile-time syn error from get_deref_field: the struct has multiple fields but none is marked with the #[deref] attribute, so the derive cannot decide which field is the Deref/DerefMut target. Exactly one field must be annotated on multi-field structs.","triggerScenarios":"Thrown at crates/bevy_derive/src/derefs.rs:94 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add #[deref] to exactly one field of the struct","Reduce the struct to a single field so no annotation is needed"],"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"}