diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-09-08 12:49:41 +0200 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-09-17 19:00:56 +0200 |
| commit | 2a8a7bb8aaf54c3c878a616884a2e4bb239b6095 (patch) | |
| tree | 7c51b2ce10d79839b24d89f898f75d8dfcba81c4 /rust/qemu-api-macros/src/lib.rs | |
| parent | dcdee1e718f9400a2bf523f2b009fb936370ae4b (diff) | |
| download | focaccia-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/qemu-api-macros/src/lib.rs')
| -rw-r--r-- | rust/qemu-api-macros/src/lib.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/rust/qemu-api-macros/src/lib.rs b/rust/qemu-api-macros/src/lib.rs index 97b2c214b6..a65a7ce2fe 100644 --- a/rust/qemu-api-macros/src/lib.rs +++ b/rust/qemu-api-macros/src/lib.rs @@ -289,11 +289,9 @@ fn derive_device_or_error(input: DeriveInput) -> Result<proc_macro2::TokenStream Ok(quote_spanned! {input.span() => unsafe impl ::qemu_api::qdev::DevicePropertiesImpl for #name { - fn properties() -> &'static [::qemu_api::bindings::Property] { - static PROPERTIES: &[::qemu_api::bindings::Property] = &[#(#properties_expanded),*]; - - PROPERTIES - } + const PROPERTIES: &'static [::qemu_api::bindings::Property] = &[ + #(#properties_expanded),* + ]; } }) } |