IIRC when you slap a new attr macro on top of the attr macros already present on an item, that new attr macro get access to the entire source of the item, including the already-present attr macros.
But you'll have to parse the types yourself from the token stream.
#[proc_macro_attribute]
#[allow(non_snake_case)]
pub fn MyMacro(attr: TokenStream, item: TokenStream) -> TokenStream {
let args: AttributeArgs = parse_macro_input!(attr as AttributeArgs);
let arg = args.get(0);
To access the proc macro attributes in my code. This requires further parsing/pattern matching on the argument but I guess you‘ll be quite close already.
- let result = Punctuated::<Ident, Token![,]>::parse_terminated(input);
+ let result = Punctuated::<Type, Token![,]>::parse_terminated(input);
EDIT: this refers to ::syn::Type, not ::syn::token::Type (more generally, the items in the ::syn::token::… module are very rarely supposed to be used directly; they're rather implicitly accessed through the Token![…] macro, such as Token![type]).
Btw, there is a way to write the whole thing a bit more succintly:
This is not the type you're passing, since neither S<U> nor [f64; 5] are idents. It seems that you're trying to pass the punctuated list of types, so the item to be parsed should be Punctuated::<Type, Token![,]>.
In the post above, I've left a link - you want syn::Type (which is for types), not syn::token::Type (which, as the module name suggests, is indeed for token type only).