Proc macro generating proc macro


I'm trying to write a proc macro extending rust with keyword arguments support.
Can I write a proc macro that generates a proc macro?


Absolutely -- an example would be proc-macro-hack which generates a proc macro here.


Do I understand correctly, that the crate using the proc-macro-generating-proc-macro must also only expose proc-macros?

Yes, that's why most crates are not proc-macro crates, but classic lib crates that depend on their own proc-macro crate, reexporting the defined proc-macros with something like pub use ::my_proc_macro_crate::my_super_proc_macro;.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.