Re: [PATCH] rust: pin-init: replace clippy `expect` with `allow`

From: Benno Lossin

Date: Sun Feb 15 2026 - 13:29:38 EST


On Sun Feb 15, 2026 at 4:19 PM CET, Tamir Duberstein wrote:
> On Sun, Feb 15, 2026 at 9:57 AM Benno Lossin <lossin@xxxxxxxxxx> wrote:
>> On Sun Feb 15, 2026 at 3:24 PM CET, Tamir Duberstein wrote:
>> > On Sun, Feb 15, 2026 at 8:22 AM Benno Lossin <lossin@xxxxxxxxxx> wrote:
>> >> @@ -1143,13 +1143,13 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
>> >> ///
>> >> /// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a
>> >> /// pointer must result in a valid `U`.
>> >> -#[expect(clippy::let_and_return)]
>> >> pub const unsafe fn cast_pin_init<T, U, E>(init: impl PinInit<T, E>) -> impl PinInit<U, E> {
>> >> // SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety
>> >> // requirements.
>> >> let res = unsafe { pin_init_from_closure(|ptr: *mut U| init.__pinned_init(ptr.cast::<T>())) };
>> >> // FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a
>> >> // cycle when computing the type returned by this function)
>> >> + #[allow(clippy::let_and_return)]
>> >
>> > Consider adding `reason = "..."`.
>>
>> Isn't the FIXME comment directly above enough? I don't want to duplicate
>> the information and the string constant explaining the reason looks
>> ugly.
>
> The FIXME explains why the allowance is needed, but it doesn't explain
> why it is an allow rather than an expect.

I don't see much value in documenting that in the code. This'll be
removed once we raise the MSRV, which should happen later this year. If
one really wants to know why it's there, there is the git log.

Cheers,
Benno