| Message ID | 20260824-unique-ref-v20-6-490735672187@kernel.org |
|---|---|
| State | Superseded |
| Delegated to: | Michał Wilczyński |
| Headers | show |
| Series | rust: add `Ownable` trait and `Owned` type | expand |
On Mon, Aug 24, 2026 at 1:19 PM Andreas Hindborg <a.hindborg@kernel.org> wrote: > > From: Oliver Mangold <oliver.mangold@pm.me> > > SAFETY comment in rustdoc example was just 'TODO'. Fixed. > > Signed-off-by: Oliver Mangold <oliver.mangold@pm.me> > Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> > Co-developed-by: Andreas Hindborg <a.hindborg@kernel.org> > Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org> Please see/link https://github.com/Rust-for-Linux/linux/issues/351. Thanks! Cheers, Miguel
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> writes: > On Mon, Aug 24, 2026 at 1:19 PM Andreas Hindborg <a.hindborg@kernel.org> wrote: >> >> From: Oliver Mangold <oliver.mangold@pm.me> >> >> SAFETY comment in rustdoc example was just 'TODO'. Fixed. >> >> Signed-off-by: Oliver Mangold <oliver.mangold@pm.me> >> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> >> Co-developed-by: Andreas Hindborg <a.hindborg@kernel.org> >> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org> > > Please see/link https://github.com/Rust-for-Linux/linux/issues/351. Do you want a link to this issue with a regular `Link:` tag? Best regards, Andreas Hindborg
On Wed, Aug 26, 2026 at 11:29 AM Andreas Hindborg <a.hindborg@kernel.org> wrote: > > Do you want a link to this issue with a regular `Link:` tag? Yeah, thanks! Cheers, Miguel
diff --git a/rust/kernel/sync/aref.rs b/rust/kernel/sync/aref.rs index ea5a16b8163a6..f26ca39b84d0d 100644 --- a/rust/kernel/sync/aref.rs +++ b/rust/kernel/sync/aref.rs @@ -142,7 +142,9 @@ pub unsafe fn from_raw(ptr: NonNull<T>) -> Self { /// /// struct Empty {} /// - /// # // SAFETY: TODO. + /// // SAFETY: The `RefCounted` implementation for `Empty` does not count references and never + /// // frees the underlying object. Thus we can act as owning an increment on the refcount for + /// // the object that we pass to the newly created `ARef`. /// unsafe impl RefCounted for Empty { /// fn inc_ref(&self) {} /// unsafe fn dec_ref(_obj: NonNull<Self>) {} @@ -150,7 +152,7 @@ pub unsafe fn from_raw(ptr: NonNull<T>) -> Self { /// /// let mut data = Empty {}; /// let ptr = NonNull::<Empty>::new(&mut data).unwrap(); - /// # // SAFETY: TODO. + /// // SAFETY: We keep `data` around longer than the `ARef`. /// let data_ref: ARef<Empty> = unsafe { ARef::from_raw(ptr) }; /// let raw_ptr: NonNull<Empty> = ARef::into_raw(data_ref); ///