summary refs log tree commit diff stats
path: root/rust/hw/core
diff options
context:
space:
mode:
authorManos Pitsidianakis <manos.pitsidianakis@linaro.org>2025-09-21 00:05:14 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2025-09-22 17:17:19 +0200
commitbed2a37b2096e1d002f3b8e881c0f6eff863ff14 (patch)
treeb16d5f538484420fff42ff2820a745e0aabebe56 /rust/hw/core
parent51d736cd71a6515808b705010ec7e38695cb7a01 (diff)
downloadfocaccia-qemu-bed2a37b2096e1d002f3b8e881c0f6eff863ff14.tar.gz
focaccia-qemu-bed2a37b2096e1d002f3b8e881c0f6eff863ff14.zip
rust/qdev: Refine the documentation for QDevProp trait
Refine the documentation to clarify:
 * `unsfae` requires that `VALUE` must be valid.
 * using `*const` instead of `&` because the latter will cause compiler
   error.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Link: https://lore.kernel.org/r/20250920160520.3699591-7-zhao1.liu@intel.com
Diffstat (limited to 'rust/hw/core')
-rw-r--r--rust/hw/core/src/qdev.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/rust/hw/core/src/qdev.rs b/rust/hw/core/src/qdev.rs
index 3ee5b24262..2735e2b2c1 100644
--- a/rust/hw/core/src/qdev.rs
+++ b/rust/hw/core/src/qdev.rs
@@ -109,9 +109,16 @@ unsafe extern "C" fn rust_resettable_exit_fn<T: ResettablePhasesImpl>(
 ///
 /// # Safety
 ///
-/// This trait is marked as `unsafe` because currently having a `const` refer to
-/// an `extern static` as a reference instead of a raw pointer results in this
-/// compiler error:
+/// This trait is marked as `unsafe` because `VALUE` must be a valid raw
+/// reference to a [`bindings::PropertyInfo`].
+///
+/// Note we could not use a regular reference:
+///
+/// ```text
+/// const VALUE: &bindings::PropertyInfo = ...
+/// ```
+///
+/// because this results in the following compiler error:
 ///
 /// ```text
 /// constructing invalid value: encountered reference to `extern` static in `const`
@@ -119,7 +126,7 @@ unsafe extern "C" fn rust_resettable_exit_fn<T: ResettablePhasesImpl>(
 ///
 /// This is because the compiler generally might dereference a normal reference
 /// during const evaluation, but not in this case (if it did, it'd need to
-/// dereference the raw pointer so this would fail to compile).
+/// dereference the raw pointer so using a `*const` would also fail to compile).
 ///
 /// It is the implementer's responsibility to provide a valid
 /// [`bindings::PropertyInfo`] pointer for the trait implementation to be safe.