mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
rust: qdev: const_refs_to_static
Now that const_refs_static can be assumed, convert the members of the DeviceImpl trait from functions to constants. This lets the compiler know that they have a 'static lifetime, and removes the need for the weird "Box::leak()". Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250908105005.2119297-10-pbonzini@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
@@ -1008,16 +1008,11 @@ const VMSTATE_HPET: VMStateDescription<HPETState> =
|
||||
// SAFETY: HPET_PROPERTIES is a valid Property array constructed with the
|
||||
// qemu_api::declare_properties macro.
|
||||
unsafe impl qemu_api::qdev::DevicePropertiesImpl for HPETState {
|
||||
fn properties() -> &'static [Property] {
|
||||
&HPET_PROPERTIES
|
||||
}
|
||||
const PROPERTIES: &'static [Property] = &HPET_PROPERTIES;
|
||||
}
|
||||
|
||||
impl DeviceImpl for HPETState {
|
||||
fn vmsd() -> Option<VMStateDescription<Self>> {
|
||||
Some(VMSTATE_HPET)
|
||||
}
|
||||
|
||||
const VMSTATE: Option<VMStateDescription<Self>> = Some(VMSTATE_HPET);
|
||||
const REALIZE: Option<fn(&Self) -> qemu_api::Result<()>> = Some(Self::realize);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user