Skip to content

internal: pin_data: use HRTB to work around trivial_bounds for Unpin - #176

Merged
nbdd0121 merged 1 commit into
mainfrom
dev/cleanup
Sep 25, 2026
Merged

nbdd0121 merged 1 commit into
mainfrom
dev/cleanup

Conversation

@nbdd0121

Copy link
Copy Markdown
Member

#[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.

`#[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@garyguo.net>
@nbdd0121
nbdd0121 merged commit ad5e5b8 into main Sep 25, 2026
55 checks passed
@nbdd0121
nbdd0121 deleted the dev/cleanup branch September 25, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant