Skip to content

Commit 42c814b

Browse files
trueptolemybonzini
authored andcommitted
rust/vmstate: Fix "cannot infer type" error in vmstate_struct
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 6182582 commit 42c814b

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

rust/qemu-api/src/vmstate.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -453,13 +453,15 @@ macro_rules! vmstate_struct {
453453
size: ::core::mem::size_of::<$type>(),
454454
flags: $crate::bindings::VMStateFlags::VMS_STRUCT,
455455
vmsd: $vmsd,
456-
..$crate::zeroable::Zeroable::ZERO $(
457-
.with_varray_flag($crate::call_func_with_field!(
458-
$crate::vmstate::vmstate_varray_flag,
459-
$struct_name,
460-
$num))
461-
$(.with_varray_multiply($factor))?)?
462-
}
456+
..$crate::zeroable::Zeroable::ZERO
457+
} $(.with_varray_flag(
458+
$crate::call_func_with_field!(
459+
$crate::vmstate::vmstate_varray_flag,
460+
$struct_name,
461+
$num
462+
)
463+
)
464+
$(.with_varray_multiply($factor))?)?
463465
};
464466
}
465467

0 commit comments

Comments
 (0)