How do I create a proc_macro_attribute?
问题 Now that proc_macros have been stabilized, how does one create such a thing? From what I've seen, there's the option of putting a #[proc_macro_attribute] annotation on a fn whatsitsname(attrs: TokenStream, code: TokenStream) -> TokenStream , but how can I register it? How can I add custom attributes? 回答1: The Rust compiler has a fairly complete test suite. When looking for examples of newly-introduced features, I frequently start there: $ rg -c proc_macro_attribute src/test/run-pass-fulldeps