Skip to content

Commit e5655e9

Browse files
trueptolemybonzini
authored andcommitted
rust/vmstate: Fix unnecessary VMState bound of with_varray_flag()
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 42c814b commit e5655e9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rust/qemu-api/src/vmstate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl VMStateField {
275275
}
276276

277277
#[must_use]
278-
pub const fn with_varray_flag<T: VMState>(mut self, flag: VMStateFlags) -> VMStateField {
278+
pub const fn with_varray_flag(mut self, flag: VMStateFlags) -> VMStateField {
279279
assert!((self.flags.0 & VMStateFlags::VMS_ARRAY.0) != 0);
280280
self.flags = VMStateFlags(self.flags.0 & !VMStateFlags::VMS_ARRAY.0);
281281
self.flags = VMStateFlags(self.flags.0 | flag.0);

0 commit comments

Comments
 (0)