qemu-rust
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/9] rust/vmstate: Support field_exists check in vmstate_stru


From: Paolo Bonzini
Subject: Re: [PATCH 1/9] rust/vmstate: Support field_exists check in vmstate_struct macro
Date: Wed, 16 Apr 2025 16:54:59 +0200

On Mon, Apr 14, 2025 at 4:29 PM Zhao Liu <zhao1.liu@intel.com> wrote:
>
> Unfortunately, at present it's not possible to have a const
> "with_exist_check" method to append test_fn after vmstate_struct (due
> to error on "constant functions cannot evaluate destructors" for `F`).

Nothing that std::mem::forget() can't fix. ;) We know that the
destructor is a no-op because FnCall is only implemented on zero-sized
functions.

Another problem with such a method, however, is that you need
VMStateField<T> for it to be type-safe. Implementing it on
bindings::VMStateField gives no guarantee that the type of the
argument to the function is the correct one. So this patch is okay
too, but perhaps add a comment (not necessarily a doc comment)
mentioning that VMStateField<T> is planned in order to remove the
extra argument?

Thanks,

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]