bevyengine/bevy · error · ReflectCloneError
expected downcast to `{expected}`, but received `{received}`
Error message
expected downcast to `{expected}`, but received `{received}` What it means
ReflectCloneError::FieldNotCloneable — while cloning a reflected container, a specific field (identified by FieldId, optional variant name, and container type path) could not be cloned, typically because it lacks a #[reflect(clone)] attribute. Add the attribute or a clone registration for that field's type.
Source
Thrown at crates/bevy_reflect/src/error.rs:54
/// [deriving `Reflect`]: derive@crate::Reflect
#[error(
"field `{}` cannot be made cloneable for `PartialReflect::reflect_clone` (are you missing a `#[reflect(clone)]` attribute?)",
full_path(.field, .variant.as_deref(), .container_type_path)
)]
FieldNotCloneable {
/// Struct field or enum variant field which cannot be cloned.
field: FieldId,
/// Variant this field is part of if the container is an enum, otherwise [`None`].
variant: Option<Cow<'static, str>>,
/// Fully qualified path of the type containing this field.
container_type_path: Cow<'static, str>,
},
/// Could not downcast to the expected type.
///
/// Realistically this should only occur when a type has incorrectly implemented [`Reflect`].
///
/// [`Reflect`]: crate::Reflect
#[error("expected downcast to `{expected}`, but received `{received}`")]
FailedDowncast {
/// The fully qualified path of the type that was expected.
expected: Cow<'static, str>,
/// The fully qualified path of the type that was received.
received: Cow<'static, str>,
},
}
fn full_path(
field: &FieldId,
variant: Option<&str>,
container_type_path: &str,
) -> alloc::string::String {
match variant {
Some(variant) => format!("{container_type_path}::{variant}::{field}"),
None => format!("{container_type_path}::{field}"),
}
}View on GitHub (pinned to 396ca72708)
Solutions
- Downcast to the actual received type instead
- Check represents::<T>() or reflect_type_path() before downcasting
- Fix registration so the expected and actual types agree
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/bevy_reflect/src/error.rs:54 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/550fd7f334733e80.
Report an issue: GitHub.