{"record":{"id":"5b23055c1aa494f7","repo":"bevyengine/bevy","slug":"from-reflect-already-set-to","errorCode":null,"errorMessage":"`from_reflect` already set to {}","messagePattern":"`from_reflect` already set to (.+?)","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bevy_reflect/derive/src/container_attributes.rs","lineNumber":446,"sourceCode":"        &mut self,\n        input: ParseStream,\n        trait_: ReflectTraitToImpl,\n    ) -> syn::Result<()> {\n        let pair = input.parse::<MetaNameValue>()?;\n        let extracted_bool = extract_bool(&pair.value, |lit| {\n            // Override `lit` if this is a `FromReflect` derive.\n            // This typically means a user is opting out of the default implementation\n            // from the `Reflect` derive and using the `FromReflect` derive directly instead.\n            if trait_ == ReflectTraitToImpl::FromReflect {\n                LitBool::new(true, Span::call_site())\n            } else {\n                lit.clone()\n            }\n        })?;\n\n        if let Some(existing) = &self.from_reflect_attrs.auto_derive {\n            if existing.value() != extracted_bool.value() {\n                return Err(syn::Error::new(\n                    extracted_bool.span(),\n                    format!(\"`{FROM_REFLECT_ATTR}` already set to {}\", existing.value()),\n                ));\n            }\n        } else {\n            self.from_reflect_attrs.auto_derive = Some(extracted_bool);\n        }\n\n        Ok(())\n    }\n\n    /// Parse `type_path` attribute.\n    ///\n    /// Examples:\n    /// - `#[reflect(type_path = false)]`\n    fn parse_type_path(\n        &mut self,\n        input: ParseStream,","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_reflect/derive/src/container_attributes.rs#L428-L464","documentation":"`#[reflect(from_reflect = <bool>)]` controls whether the `Reflect` derive also generates a `FromReflect` impl. The value is stored once; `parse_from_reflect` (crates/bevy_reflect/derive/src/container_attributes.rs:427) errors with \"`from_reflect` already set to {previous}\" if it is set again with a DIFFERENT value. Note the `FromReflect` derive forces the value to `true` (the mapper override in the source), so an explicit `false` combined with `#[derive(FromReflect)]` is the typical conflict.","triggerScenarios":"`#[derive(Reflect, FromReflect)]` together with `#[reflect(from_reflect = false)]` on the same type; or two contradictory settings like `#[reflect(from_reflect = true)]` and `#[reflect(from_reflect = false)]` across lists. Setting the same value twice is fine.","commonSituations":"Opting a type out of auto FromReflect while a derive or a second attribute still opts in; refactors that add `#[derive(FromReflect)]` to a type that previously carried `from_reflect = false` to dodge a field-bound issue.","solutions":["Pick one mechanism: either `#[derive(FromReflect)]` (implies true) or an explicit `#[reflect(from_reflect = false)]`, not both","If you need `false`, remove the `FromReflect` derive and implement `FromReflect` manually if still required","Keep a single `#[reflect(...)]` list so the setting appears once"],"exampleFix":"// before: derive forces true, attribute says false -> \"`from_reflect` already set to false\"\n#[derive(Reflect, FromReflect)]\n#[reflect(from_reflect = false)]\nstruct Foo;\n\n// after: choose one opt-in\n#[derive(FromReflect)] // implies from_reflect = true\nstruct Foo;","handlingStrategy":"validation","validationCode":"null","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never combine #[derive(FromReflect)] with #[reflect(from_reflect = false)]","Pick one opt-in mechanism per type and document it","When disabling auto-derives, grep the type for any derive or attribute that silently re-enables it"],"tags":["bevy","reflect","derive-macro","from-reflect","compile-error"],"backgroundTag":"derive-macro-attribute-conflict","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}