[PATCH 09/10] rust: pin-init: cleanup workaround for old Rust compiler
From: Gary Guo
Date: Tue Apr 28 2026 - 09:37:07 EST
The workaround mentions it's for Rust versions before 1.81. The minimum is
now 1.82, thus clean up.
Signed-off-by: Gary Guo <gary@xxxxxxxxxxx>
---
rust/pin-init/internal/src/init.rs | 9 +--------
rust/pin-init/src/lib.rs | 18 ++----------------
2 files changed, 3 insertions(+), 24 deletions(-)
diff --git a/rust/pin-init/internal/src/init.rs b/rust/pin-init/internal/src/init.rs
index daa3f1c6466e..a37309e7b10a 100644
--- a/rust/pin-init/internal/src/init.rs
+++ b/rust/pin-init/internal/src/init.rs
@@ -172,14 +172,7 @@ fn assert_zeroable<T: ?::core::marker::Sized>(_: *mut T)
init(slot).map(|__InitOk| ())
};
// SAFETY: TODO
- let init = unsafe { ::pin_init::#init_from_closure::<_, #error>(init) };
- // FIXME: this let binding is required to avoid a compiler error (cycle when computing the
- // opaque type returned by this function) before Rust 1.81. Remove after MSRV bump.
- #[allow(
- clippy::let_and_return,
- reason = "some clippy versions warn about the let binding"
- )]
- init
+ unsafe { ::pin_init::#init_from_closure::<_, #error>(init) }
}})
}
diff --git a/rust/pin-init/src/lib.rs b/rust/pin-init/src/lib.rs
index 9b76cf5597c6..80c476e605f7 100644
--- a/rust/pin-init/src/lib.rs
+++ b/rust/pin-init/src/lib.rs
@@ -1139,14 +1139,7 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
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: this let binding is required to avoid a compiler error (cycle when computing the opaque
- // type returned by this function) before Rust 1.81. Remove after MSRV bump.
- #[allow(
- clippy::let_and_return,
- reason = "some clippy versions warn about the let binding"
- )]
- res
+ unsafe { pin_init_from_closure(|ptr: *mut U| init.__pinned_init(ptr.cast::<T>())) }
}
/// Changes the to be initialized type.
@@ -1158,14 +1151,7 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
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: this let binding is required to avoid a compiler error (cycle when computing the opaque
- // type returned by this function) before Rust 1.81. Remove after MSRV bump.
- #[allow(
- clippy::let_and_return,
- reason = "some clippy versions warn about the let binding"
- )]
- res
+ unsafe { init_from_closure(|ptr: *mut U| init.__init(ptr.cast::<T>())) }
}
/// An initializer that leaves the memory uninitialized.
--
2.51.2