bevyengine/bevy · error · VariantInfoError
variant type mismatch: expected {expected:?}, received {rece
Error message
variant type mismatch: expected {expected:?}, received {received:?} What it means
VariantInfoError::TypeMismatch — a check on an enum's VariantInfo expected the variant to be a certain VariantType (Struct/Tuple/Unit) but found another. The expected and received variant types are in the fields; callers should match on the actual variant type.
Source
Thrown at crates/bevy_reflect/src/enums/variants.rs:47
/// ```
Tuple,
/// Unit enums take the form:
///
/// ```
/// enum MyEnum {
/// A
/// }
/// ```
Unit,
}
/// A [`VariantInfo`]-specific error.
#[derive(Debug, Error)]
pub enum VariantInfoError {
/// Caused when a variant was expected to be of a certain [type], but was not.
///
/// [type]: VariantType
#[error("variant type mismatch: expected {expected:?}, received {received:?}")]
TypeMismatch {
/// Expected variant type.
expected: VariantType,
/// Received variant type.
received: VariantType,
},
}
/// A container for compile-time enum variant info.
#[derive(Clone, Debug)]
pub enum VariantInfo {
/// Struct enums take the form:
///
/// ```
/// enum MyEnum {
/// A {
/// foo: usize
/// }View on GitHub (pinned to 396ca72708)
Solutions
- Match on the actual VariantType before constructing or using VariantInfo
- Fix the expected variant type to match the enum definition
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/bevy_reflect/src/enums/variants.rs:47 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/84845f4623ef07e6.
Report an issue: GitHub.