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: add `ForLt` trait for higher-ranked lifetime support Date: Tue, 26 May 2026 06:47:04 +1000 Message-ID: In-Reply-To: <20260525202921.124698-23-dakr@kernel.org> References: <20260525202921.124698-1-dakr@kernel.org> <20260525202921.124698-23-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 The ForLt infrastructure by Gary Guo. The trait: ```rust pub unsafe trait ForLt { type Of<'a>: 'a; fn cast_ref<'r, 'short: 'r, 'long: 'short>(long: &'r Self::Of<'long>) -> &'r Self::Of<'short> { unsafe { core::mem::transmute(long) } } } ``` The proc macro (`ForLt!`) generates covariance proofs and well-formedness checks. The `visit_macro` handler conservatively assumes macro invocations may contain lifetimes: ```rust fn visit_macro(&mut self, _: &syn::Macro) { self.1 = true; } ``` The WF proof works around a Rust compiler soundness bug (rust-lang/rust#152489) by using a struct rather than a function to avoid implied WF bounds. The implementation is thorough -- the covariance prover handles references, pointers, tuples, arrays, slices, and falls back to compiler-checked proofs for complex types. Licensed Apache-2.0 OR MIT for future pin-init reuse. One note: the `UnsafeForLtImpl` type is documented as "unsafe-to-refer-to" but there's no actual mechanism preventing misuse beyond doc comments. This is a known limitation of the pattern. --- Generated by Claude Code Patch Reviewer