@@ -91,6 +91,21 @@ fn types_must_be_equal<T, U>(_: T)
}
};
};
+
+ ($t:ty, $i:tt, $ti:ty, num = $num:ident) => {
+ const _: () = {
+ #[allow(unused)]
+ fn assert_field_type(v: $t) {
+ fn types_must_be_equal<T, U>(_: T)
+ where
+ T: $crate::assertions::EqType<Itself = U>,
+ {
+ }
+ let index: usize = v.$num.try_into().unwrap();
+ types_must_be_equal::<_, &$ti>(&v.$i[index]);
+ }
+ };
+ };
}
/// Assert that an expression matches a pattern. This can also be
@@ -447,7 +447,7 @@ macro_rules! vmstate_struct {
.as_ptr() as *const ::std::os::raw::c_char,
$(num_offset: $crate::offset_of!($struct_name, $num),)?
offset: {
- $crate::assert_field_type!($struct_name, $field_name, $type);
+ $crate::assert_field_type!($struct_name, $field_name, $type $(, num = $num)?);
$crate::offset_of!($struct_name, $field_name)
},
size: ::core::mem::size_of::<$type>(),