Skip to content

Allow other attributes in #[pin_data] structs#122

Open
nertpinx wants to merge 1 commit intoRust-for-Linux:mainfrom
nertpinx:extras
Open

Allow other attributes in #[pin_data] structs#122
nertpinx wants to merge 1 commit intoRust-for-Linux:mainfrom
nertpinx:extras

Conversation

@nertpinx
Copy link

When using a macro with custom attributes in a #[pin_data] struct it can mess up the generated __Unpin struct.

This commit moves the decision-making of which attributes to keep into a new, separate function, so that it is unified in all places. Only #[cfg] and #[doc] attributes are kept since all other can cause issues.

With this commit a struct can use both #[pin] and other custom attributes, allowing combining multiple attribute macros without clashing.

To keep this functionality this commit also adds a test with a custom attribute that fails without this fix.

This is a rebased version of the old #94 which was originally based on the now-removed dev/syn2 branch.

When using a macro with custom attributes in a `#[pin_data]` struct it
can mess up the generated `__Unpin` struct.

This commit moves the decision-making of which attributes to keep into a
new, separate function, so that it is unified in all places.  Only
`#[cfg]` and `#[doc]` attributes are kept since all other can cause
issues.

With this commit a struct can use both #[pin] and other custom
attributes, allowing combining multiple attribute macros without
clashing.

To keep this functionality this commit also adds a test with a custom
attribute that fails without this fix.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
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