summary refs log tree commit diff stats
path: root/rust/hw/timer
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-09-08 12:49:41 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2025-09-17 19:00:56 +0200
commit2a8a7bb8aaf54c3c878a616884a2e4bb239b6095 (patch)
tree7c51b2ce10d79839b24d89f898f75d8dfcba81c4 /rust/hw/timer
parentdcdee1e718f9400a2bf523f2b009fb936370ae4b (diff)
downloadfocaccia-qemu-2a8a7bb8aaf54c3c878a616884a2e4bb239b6095.tar.gz
focaccia-qemu-2a8a7bb8aaf54c3c878a616884a2e4bb239b6095.zip
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>
Diffstat (limited to 'rust/hw/timer')
-rw-r--r--rust/hw/timer/hpet/src/device.rs9
1 files changed, 2 insertions, 7 deletions
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<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);
 }