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: Mon, 25 May 2026 19:29:15 +1000 Message-ID: In-Reply-To: <20260521233501.1191842-22-dakr@kernel.org> References: <20260521233501.1191842-1-dakr@kernel.org> <20260521233501.1191842-22-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 **Author:** Gary Guo (with Danilo's additions for macro handling) This is the most complex patch. The `ForLt` trait provides a way to represe= nt types generic over a lifetime: ```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>; } ``` The `cast_ref` uses transmute, justified by the covariance requirement. The proc macro (`ForLt!()`) generates: 1. `WithLt` trait implementations for lifetime projection 2. Covariance proofs via `ProveWfN` structs and `prove_covariant_N` functio= ns 3. Well-formedness checks by substituting `'static` for the lifetime **Observation on the Prover:** The prover's handling of `Type::Macro` (Dani= lo's addition) conservatively defers to compiler-assisted proofs. The comme= nt in the cover letter asks Gary for review of this =E2=80=94 it correctly = handles the fact that proc macros can't expand `macro_rules!` invocations. **Minor nit:** The doc comment says "the lifetime parameter can be soundly = shorterned" (typo: "shortened"). The soundness argument relies on the compiler catching non-covariant types = at the proof site. The `WF` phantom parameter in `UnsafeForLtImpl= ` ensures that `Of<'static>` is well-formed, working around a known Rust co= mpiler soundness issue (referenced as rust-lang/rust#152489). This is subtle but appears correct. The `cast_ref` in ForLt only shortens l= ifetimes, which is sound for covariant types. --- --- Generated by Claude Code Patch Reviewer