internal: add tuple struct support in pin_data and pin_init! (V2)#155
Open
mqqz wants to merge 4 commits into
Open
internal: add tuple struct support in pin_data and pin_init! (V2)#155mqqz wants to merge 4 commits into
pin_data and pin_init! (V2)#155mqqz wants to merge 4 commits into
Conversation
Add plumbing for tuple struct support to `#[pin_data]` by generating tuple struct projections and tuple-aware pin-data metadata. Keep the projection API native to Rust tuple structs, so projected fields are accessed as `.0`, `.1`, etc. instead of introducing synthetic public field names. Signed-off-by: Mohamad Alsadhan <mo@sdhn.cc>
Expand `init!` and `pin_init!` to initialize tuple structs using both indexed brace syntax and tuple-constructor syntax. Add tuple-specific runtime and UI coverage for the basic initializer forms, duplicate/missing fields, invalid indices, and syntax errors. Signed-off-by: Mohamad Alsadhan <mo@sdhn.cc>
Extend tuple-struct coverage with the semantic cases that are easiest to review independently from the implementation changes. Add runtime coverage for generic and const-generic tuple structs, `Unpin` behaviour with `!Unpin` field types, pinned drop, and fallible partial-init rollback. Signed-off-by: Mohamad Alsadhan <mo@sdhn.cc>
Handle tuple structs whose fields or constructor arguments are removed by `#[cfg]`. For tuple projections and tuple-constructor lowering, generate the needed cfg-specific layouts instead of trying to evaluate user cfgs inside the proc macro, and let rustc select the active branch. Add regression tests covering cfg-stripped tuple fields, cfg-stripped tuple constructor arguments, and feature-dependent field layouts. Signed-off-by: Mohamad Alsadhan <mo@sdhn.cc>
c9dab99 to
1f2c279
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.
Replaces #113.
This adds tuple struct support to
#[pin_data],init!, andpin_init!.The projected form of a tuple struct is also a tuple struct, so projected fields are accessed with native tuple syntax (
.0,.1, ...), which keeps the generated API closer toordinary Rust and avoids exposing synthetic field names (also makes it easier fields are cfg'd out).
#[pin_data]pin_init!(Foo { 0 <- ..., 1: ... })pin_init!(Foo(...))#[cfg]Notes
._0like last time.#[cfg]conditions in the proc macroTests
Added coverage for:
#[pin]interaction with!Unpinfield typesComparison with the old PR
This replaces the earlier attempt in #113.
Compared with that PR, this version is intentionally narrower and easier to review:
Closes: #85