Re: [PATCH] rust: pin-init: internal: pin_data: use HRTB to work around `trivial_bounds` for `Unpin`

From: Gary Guo

Date: Fri Sep 25 2026 - 07:46:20 EST


On Tue Sep 22, 2026 at 10:13 PM BST, Gary Guo wrote:
> From: Gary Guo <gary@xxxxxxxxxxx>
>
> `#[pin_data]` generates a `Unpin` implementation for the user, which
> requires reasoning using field types. This is rejected by rustc as "trivial
> bounds", which can only be specified using the
> `#![feature(trivial_bounds)]`.
>
> Currently we use an extra lifetime in `__Unpin` to work around this; use
> HRTB to introduce a dummy lifetime can achieve the same, which the
> `Zeroable` implementation already uses.
>
> Unify the `Unpin` impl to also use the same HRTB trick that `Zeroable`
> uses. This produces slightly better error message and slightly shorter
> expansion.
>
> Signed-off-by: Gary Guo <gary@xxxxxxxxxxx>

Applied to pin-init-next.

Best,
Gary

> ---
> rust/pin-init/internal/src/pin_data.rs | 35 +++++++++-----------------
> rust/pin-init/src/__internal.rs | 16 ------------
> 2 files changed, 12 insertions(+), 39 deletions(-)