From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: rust: implement `ForeignOwnable` for `Owned` Date: Fri, 27 Feb 2026 15:11:58 +1000 Message-ID: In-Reply-To: <20260224-unique-ref-v16-9-c21afcb118d3@kernel.org> References: <20260224-unique-ref-v16-0-c21afcb118d3@kernel.org> <20260224-unique-ref-v16-9-c21afcb118d3@kernel.org> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review The `ForeignOwnable` impl allows `Owned` to be stored in C data structur= es like `XArray`. ```rust #[repr(transparent)] pub struct Owned { ptr: NonNull, } ``` The `#[repr(transparent)]` is added here, needed for the `ForeignOwnable` i= mplementation since it ensures `Owned` has the same layout as `NonNull`. The `BorrowedMut` type is `Pin<&'a mut T>`, which is correct =E2=80=94 it m= aintains the pin invariant since `Owned` pins its contents. ```rust unsafe fn borrow_mut<'a>(ptr: *mut kernel::ffi::c_void) -> Self::BorrowedMu= t<'a> { let inner =3D unsafe { &mut *ptr.cast() }; unsafe { Pin::new_unchecked(inner) } } ``` The safety reasoning about not moving out of `inner` and not handing out mu= table references when `T: !Unpin` is correct =E2=80=94 `Pin<&mut T>` only p= rovides `DerefMut` when `T: Unpin`. --- Generated by Claude Code Patch Reviewer