]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
rust/vmstate: Fix unnecessary VMState bound of with_varray_flag()
authorZhao Liu <zhao1.liu@intel.com>
Tue, 18 Mar 2025 13:02:11 +0000 (21:02 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 21 Mar 2025 11:56:00 +0000 (12:56 +0100)
The VMState type bound is not used in with_varray_flag().

And for vmstate_struct, Rust cannot infer the type of `num` from the
call_func_with_field(), so this causes the compiling error because it
complains "cannot satisfy `_: VMState`" in with_varray_flag().

Note Rust can infer the type in vmstate_of macro so that
with_varray_flag() can work at there. It is possible that the different
initialization ways in the two macros cause differences in Rust's
type inference.

But in fact, the VMState type bound is not used in with_varray_flag()
and vmstate_varray_flag() has already checked the VMState type, it's
safe to drop VMState bound of with_varray_flag(), which can fix the
above compiling error.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20250318130219.1799170-8-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/qemu-api/src/vmstate.rs

index 3be3a7260fe9015c0410ed7e19872f65345b970c..792a74fdfc088724fbda266458ea3fa292e4cf7e 100644 (file)
@@ -275,7 +275,7 @@ impl VMStateField {
     }
 
     #[must_use]
-    pub const fn with_varray_flag<T: VMState>(mut self, flag: VMStateFlags) -> VMStateField {
+    pub const fn with_varray_flag(mut self, flag: VMStateFlags) -> VMStateField {
         assert!((self.flags.0 & VMStateFlags::VMS_ARRAY.0) != 0);
         self.flags = VMStateFlags(self.flags.0 & !VMStateFlags::VMS_ARRAY.0);
         self.flags = VMStateFlags(self.flags.0 | flag.0);