Hi guys, I have been developing a custom inner attribute as procedural-macro. The problem I found is that the input tokens seem to be wrapped into a pub mod
without identifier and will throw an error if I parse it with crate
. Is there any workaround on this or an easy way to obtain the tokens of entire crate instead of inner attribute?
Here is an example:
#![feature(custom_inner_attributes)]
#![crate::inner_attribute_name]
...//input
In my crate where the proc-macro
is defined:
pub fn attribute_name(tokens: TokenStream) -> TokenStream {
let input: ItemMod = syn::parse2(tokens); // This will be an error
// If I call tokens.to_string() and print it, I have
// pub mod {
// ... (all the input source codes)
//}
}