[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 08/17] rust/vmstate: Fix "cannot infer type" error in vmstate_str
From: |
Zhao Liu |
Subject: |
[PATCH 08/17] rust/vmstate: Fix "cannot infer type" error in vmstate_struct |
Date: |
Mon, 17 Mar 2025 23:12:27 +0800 |
Rust cannot infer the type (it should be VMStateField) after
Zeroable::ZERO, which cause the compiling error.
To fix this error, call with_varray_flag() after VMStateField's
initialization.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
rust/qemu-api/src/vmstate.rs | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/rust/qemu-api/src/vmstate.rs b/rust/qemu-api/src/vmstate.rs
index 8adef175634a..a9d97d9a856e 100644
--- a/rust/qemu-api/src/vmstate.rs
+++ b/rust/qemu-api/src/vmstate.rs
@@ -453,13 +453,15 @@ macro_rules! vmstate_struct {
size: ::core::mem::size_of::<$type>(),
flags: $crate::bindings::VMStateFlags::VMS_STRUCT,
vmsd: &$vmsd,
- ..$crate::zeroable::Zeroable::ZERO $(
- .with_varray_flag($crate::call_func_with_field!(
- $crate::vmstate::vmstate_varray_flag,
- $struct_name,
- $num))
- $(.with_varray_multiply($factor))?)?
- }
+ ..$crate::zeroable::Zeroable::ZERO
+ } $(.with_varray_flag(
+ $crate::call_func_with_field!(
+ $crate::vmstate::vmstate_varray_flag,
+ $struct_name,
+ $num
+ )
+ )
+ $(.with_varray_multiply($factor))?)?
};
}
--
2.34.1
- Re: [PATCH 04/17] rust/vmstate: Use ident instead of expr to parse vmsd in vmstate_struct macro, (continued)
[PATCH 08/17] rust/vmstate: Fix "cannot infer type" error in vmstate_struct,
Zhao Liu <=
[PATCH 14/17] rust/vmstate: Add unit test for vmstate_of macro, Zhao Liu, 2025/03/17
[PATCH 15/17] rust/vmstate: Add unit test for vmstate_{of|struct} macro, Zhao Liu, 2025/03/17
[PATCH 11/17] rust/vmstate: Re-implement VMState trait for timer binding, Zhao Liu, 2025/03/17
[PATCH 17/17] rust/vmstate: Add unit test for vmstate_validate, Zhao Liu, 2025/03/17
[PATCH 16/17] rust/vmstate: Add unit test for pointer case, Zhao Liu, 2025/03/17
Re: [PATCH 00/17] rust/vmstate: Clean up, fix, enhance & test, Paolo Bonzini, 2025/03/17