From 2a8a7bb8aaf54c3c878a616884a2e4bb239b6095 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 8 Sep 2025 12:49:41 +0200 Subject: 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 Link: https://lore.kernel.org/r/20250908105005.2119297-10-pbonzini@redhat.com Signed-off-by: Paolo Bonzini --- rust/hw/timer/hpet/src/device.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'rust/hw/timer') diff --git a/rust/hw/timer/hpet/src/device.rs b/rust/hw/timer/hpet/src/device.rs index eb5bd042b1..dd5326a40d 100644 --- a/rust/hw/timer/hpet/src/device.rs +++ b/rust/hw/timer/hpet/src/device.rs @@ -1008,16 +1008,11 @@ const VMSTATE_HPET: VMStateDescription = // 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> { - Some(VMSTATE_HPET) - } - + const VMSTATE: Option> = Some(VMSTATE_HPET); const REALIZE: Option qemu_api::Result<()>> = Some(Self::realize); } -- cgit 1.4.1