internal: pin_data: use HRTB to work around trivial_bounds for Unpin - #176
Merged
Merged
Conversation
`#[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
force-pushed
the
dev/cleanup
branch
from
September 25, 2026 11:39
b04d120 to
dd7e52d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#[pin_data]generates aUnpinimplementation 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
__Unpinto work around this; use HRTB to introduce a dummy lifetime can achieve the same, which theZeroableimplementation already uses.Unify the
Unpinimpl to also use the same HRTB trick thatZeroableuses. This produces slightly better error message and slightly shorter expansion.