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: types: introduce ForLt base trait for CovariantForLt Date: Thu, 04 Jun 2026 12:08:39 +1000 Message-ID: In-Reply-To: <20260603011020.2073650-3-dakr@kernel.org> References: <20260603011020.2073650-1-dakr@kernel.org> <20260603011020.2073650-3-dakr@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 trait split is well-designed: ```rust pub trait ForLt { type Of<'a>: 'a; unsafe fn cast_ref_unchecked<'r, 'short: 'r, 'long: 'short>(...) -> ...; } pub unsafe trait CovariantForLt: ForLt { fn cast_ref<'r, 'short: 'r, 'long: 'short>(...) -> ...; } ``` `ForLt` is not `unsafe` to implement (correct =E2=80=94 it makes no varianc= e guarantee), while `cast_ref_unchecked` is `unsafe` to call. `CovariantFor= Lt` is `unsafe` to implement (the implementer guarantees covariance) with a= safe `cast_ref`. The `ForLtImpl` helper struct correctly omits the `const N: usize` paramete= r since no covariance proof needs to be embedded: ```rust pub struct ForLtImpl(PhantomData<(WF, T)>); ``` The blanket `ForLt` impl on `CovariantForLtImpl` correctly covers all `N`: ```rust impl WithLt<'a>, WF, const N: usize> ForLt for Covarian= tForLtImpl { type Of<'a> =3D >::Of; } ``` This is needed so that `CovariantForLt: ForLt` is satisfied. The macro refactoring (`resolve_hrt`, `ty_static` shared helpers) is clean.= The new `for_lt()` macro function correctly skips the covariance `Prover` = pass. **Minor observation:** `CovariantForLt::cast_ref` still contains its own `t= ransmute` rather than delegating to `unsafe { Self::cast_ref_unchecked(long= ) }`. This is fine for performance (both are `#[inline(always)]`), but usin= g the unchecked version would make the relationship between the two methods= more explicit. Not worth a respin. --- Generated by Claude Code Patch Reviewer