Call attribute macro in the implementation of another attribute macro

Viewed 144

I cannot find how to inject a attribute macro in the result of my attribute macro.

Here is an example of a kind of injection:

use quote::quote;
use proc_macro::TokenStream;

#[proc_macro_attribute]
pub fn my_test(_: TokenStream, item: TokenStream) -> TokenStream {
    let result = quote! {
        #[test]
        #item
    };

    result.into()
}

It generate an error at compile time. Can we call another attribute macro ?

Documentation neither refute nor confirm it.

0 Answers
Related