rust: sync: document `PhantomData` in `Arc`
PATCH v2 1/1 rust: sync: document `PhantomData` in `Arc`
Add a comment explaining the relevant semantics of PhantomData. This should help future readers who may, as I did, assume that this field is redundant at first glance.
---
Changes in v2:
- Reworked as a new comment (Boqun Feng, Miguel Ojeda).
- Link to v1: https://lore.kernel.org/r/[email protected]
--- rust/kernel/sync/arc.rs | 8 ++++++++ 1 file changed, 8 insertions(+)
rust/kernel/sync/arc.rs +8 -0
@@ -127,6 +127,14 @@/// ``` pub struct Arc <T : ?Sized > { ptr:NonNull <ArcInner <T >>, +// NB: this informs dropck that objects of type `ArcInner<T>` may be used in `<Arc<T> as +// Drop>::drop`. Note that dropck already assumes that objects of type `T` may be used in +// `<Arc<T> as Drop>::drop` and the distinction between `T` and `ArcInner<T>` is not presently +// meaningful with respect to dropck - but this may change in the future so this is left here +// out of an abundance of caution. +// +// See https://doc.rust-lang.org/nomicon/phantom-data.html#generic-parameters-and-drop-checking +// for more detail on the semantics of dropck in the presence of `PhantomData`. _p:PhantomData <ArcInner <T >>, }
---
base-commit: ae7851c29747fa3765ecb722fe722117a346f988
change-id: 20241104-simplify-arc-70c3574b5fac
Best regards,
Signature · 1 line
Tamir Duberstein <[email protected]>
Gentle bump.
Quoted 6 lines · Tamir Duberstein
Add a comment explaining the relevant semantics of
PhantomData. This should help future readers who may, as I did, assume that this field is redundant at first glance.Signed-off-by Tamir Duberstein <[email protected]>
Miguel Ojeda
AppliedQuoted 6 lines · Tamir Duberstein
Add a comment explaining the relevant semantics of
PhantomData. This should help future readers who may, as I did, assume that this field is redundant at first glance.Signed-off-by Tamir Duberstein <[email protected]>
Applied to rust-next -- thanks everyone!
Cheers,
Miguel