-
When For now I can easily fix it by making sure my proc macro is applied first, but I'd much prefer if my users didn't have to care about that :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Short answer: If the attributes are kept rustc will not compile the programs and will error with Longer answer: So right now I see two possible solutions:
In your case you could see if you want to parse the
|
Beta Was this translation helpful? Give feedback.
-
They do, but there is an extra step where the attribute macro needs to attach a derive that identifies which inert attributes the attribute macro is claiming. #[proc_macro_derive(serde_as_attributes, attributes(serde_as))]
pub fn attributes(_: TokenStream) -> TokenStream {
TokenStream::new()
}
// then put derive(serde_as_attributes) on input |
Beta Was this translation helpful? Give feedback.
Short answer: If the attributes are kept rustc will not compile the programs and will error with
expected an inert attribute, found an attribute macro
.Longer answer:
Currently, the
serde_as
system is implemented as a proc-macro attribute, which do not have the luxury of declaring additional attribute names which it will consume. Derive macros can do that, and they do not have to remove the field attributes. In fact, they cannot remove them.Field attributes are still required though, so either they re-use the
serde_as
attribute name or an unknown attribute name. Unknown attributes would also cause compiler errors. Sinceserde_as
is re-used it causes the error message above, since you are…