Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20241107-simplify-arc-v2-1-7256e638aac1@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

authored by

Tamir Duberstein and committed by
Miguel Ojeda
2dde1c8b 3f4223c0

+8
+8
rust/kernel/sync/arc.rs
··· 127 127 /// ``` 128 128 pub struct Arc<T: ?Sized> { 129 129 ptr: NonNull<ArcInner<T>>, 130 + // NB: this informs dropck that objects of type `ArcInner<T>` may be used in `<Arc<T> as 131 + // Drop>::drop`. Note that dropck already assumes that objects of type `T` may be used in 132 + // `<Arc<T> as Drop>::drop` and the distinction between `T` and `ArcInner<T>` is not presently 133 + // meaningful with respect to dropck - but this may change in the future so this is left here 134 + // out of an abundance of caution. 135 + // 136 + // See https://doc.rust-lang.org/nomicon/phantom-data.html#generic-parameters-and-drop-checking 137 + // for more detail on the semantics of dropck in the presence of `PhantomData`. 130 138 _p: PhantomData<ArcInner<T>>, 131 139 } 132 140