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: auxiliary: generalize Registration over ForLt Date: Tue, 26 May 2026 06:47:04 +1000 Message-ID: In-Reply-To: <20260525202921.124698-24-dakr@kernel.org> References: <20260525202921.124698-1-dakr@kernel.org> <20260525202921.124698-24-dakr@kernel.org> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review `Registration` becomes `Registration<'a, F: ForLt>`. The key split: ```rust + pub unsafe fn new_with_lt( + parent: &'a device::Device, + ... + data: impl PinInit, E>, + ) -> Result ``` vs the safe version: ```rust + pub fn new(...) -> Result + where + F::Of<'a>: 'static, + { + unsafe { Self::new_with_lt(parent, name, id, modname, data) } + } ``` The `new_with_lt` is unsafe because `mem::forget()` could prevent `Drop` from running, leaving borrowed references dangling. The `new()` is safe when data is `'static` because there are no borrowed references to dangle. The `registration_data` method uses `ForLt::cast_ref` to shorten the stored `'static` lifetime: ```rust + let pinned: Pin<&F::Of<'static>> = unsafe { wrapper.map_unchecked(|w| &w.data) }; + Ok(unsafe { Pin::new_unchecked(F::cast_ref(pinned.get_ref())) }) ``` The `PhantomData<(fn(&'a ()) -> &'a (), F)>` in Registration ensures `'a` is invariant (via the function pointer type), which is correct -- the registration must not outlive the scope it was created in. The `Registration` no longer wraps in `Devres` -- it's now directly held by the driver. The `Send`/`Sync` impls use `for<'a> F::Of<'a>: Send` instead of `T: Send + Sync`. Dropping `Sync` requirement from the `Send` bound seems intentional -- a `Registration` is moved, not shared. The transmute from `RegistrationData>` to `RegistrationData>` is sound because lifetimes don't affect layout. --- Generated by Claude Code Patch Reviewer