Re: [PATCH] rust: pin-init: replace clippy `expect` with `allow`
From: Gary Guo
Date: Sun Feb 15 2026 - 20:37:02 EST
On 2026-02-15 13:22, Benno Lossin wrote:
> `clippy` has changed behavior in [1] (Rust 1.95) where it no longer
> warns about the `let_and_return` lint when a comment is placed between
> the let binding and the return expression. Nightly thus fails to build,
> because the expectation is no longer fulfilled.
>
> Thus replace the expectation with an `allow`.
>
> Link: https://github.com/rust-lang/rust-clippy/pull/16461 [1]
> Signed-off-by: Benno Lossin <lossin@xxxxxxxxxx>
I think it's worth adding a comment (or reason) that this is no longer needed after 1.95.
With that:
Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
> ---
> rust/pin-init/src/lib.rs | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/rust/pin-init/src/lib.rs b/rust/pin-init/src/lib.rs
> index 49945fc07f25..fe4c85ae3f02 100644
> --- a/rust/pin-init/src/lib.rs
> +++ b/rust/pin-init/src/lib.rs
> @@ -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)]
> res
> }
>
> @@ -1159,13 +1159,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_init<T, U, E>(init: impl Init<T, E>) -> impl Init<U, E> {
> // SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety
> // requirements.
> let res = unsafe { init_from_closure(|ptr: *mut U| init.__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)]
> res
> }
>
>
> base-commit: ca4ee40bf13dbd3a4be3b40a00c33a1153d487e5