From: Gary Guo Date: Wed, 27 May 2026 17:19:57 +0000 (+0100) Subject: rust: pin-init: remove `E` from `InitClosure` X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f85906616ec70d1d0178073b16ebd1c7f6ff1ee7;p=thirdparty%2Flinux.git rust: pin-init: remove `E` from `InitClosure` Move `E` from type to trait impl block. This greatly shortens the monomorphized type names. The `__pinned_init` function name is only slightly shortened as it still encodes the `E` as part of `PinInit` in the symbol. `T` cannot be moved to trait impl block otherwise it will start to conflict with the `impl Init for T` as Rust cannot deduce that there're no types that fulfill `T: FnOnce(*mut T)`. Link: https://patch.msgid.link/20260527-pin-init-sync-v1-6-e20335ed2501@garyguo.net Signed-off-by: Gary Guo --- diff --git a/rust/pin-init/src/lib.rs b/rust/pin-init/src/lib.rs index 9732af32795c6..fd40c8f244a1e 100644 --- a/rust/pin-init/src/lib.rs +++ b/rust/pin-init/src/lib.rs @@ -1096,11 +1096,11 @@ where /// /// It is unsafe to create this type, since the closure needs to fulfill the same safety /// requirement as the `__pinned_init`/`__init` functions. -struct InitClosure(F, __internal::PhantomInvariant<(E, T)>); +struct InitClosure(F, __internal::PhantomInvariant); // SAFETY: While constructing the `InitClosure`, the user promised that it upholds the // `__init` invariants. -unsafe impl Init for InitClosure +unsafe impl Init for InitClosure where F: FnOnce(*mut T) -> Result<(), E>, { @@ -1112,7 +1112,7 @@ where // SAFETY: While constructing the `InitClosure`, the user promised that it upholds the // `__pinned_init` invariants. -unsafe impl PinInit for InitClosure +unsafe impl PinInit for InitClosure where F: FnOnce(*mut T) -> Result<(), E>, {