-
Notifications
You must be signed in to change notification settings - Fork 27
Allow other attributes in #[pin_data] structs #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| [package] | ||
| name = "dummy" | ||
| version = "0.0.0" | ||
| edition = "2024" | ||
|
|
||
| license = "MIT OR Apache-2.0" | ||
| description = "Proc macro only for test reproduction." | ||
|
|
||
| publish = false | ||
|
|
||
| [lib] | ||
| proc-macro = true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #[proc_macro_derive(Dummy, attributes(dummy_attr))] | ||
| pub fn derive_device(_: proc_macro::TokenStream) -> proc_macro::TokenStream { | ||
| proc_macro::TokenStream::new() | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| use dummy::Dummy; | ||
| use pin_init::*; | ||
|
|
||
| #[pin_data] | ||
| #[derive(Dummy)] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I'd rather we use something that already exists. How about perhaps test compatibility with serde? @BennoLossin thoughts on introducing serde as test-only dep? |
||
| struct Pointless { | ||
| #[pin] | ||
| #[dummy_attr] | ||
| #[cfg(test)] | ||
| member: i8, | ||
| #[pin] | ||
| #[dummy_attr] | ||
| #[cfg(not(test))] | ||
| member: u8, | ||
| } | ||
|
|
||
| #[test] | ||
| fn multiple_attributes() { | ||
| stack_pin_init!(let p = init!(Pointless { member: 0 })); | ||
| println!("{}", p.member); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think doc needs to be kept. The generated structs are hidden anyway.
In
init!()macro we currently only keep the cfg attributes or generated code.