This is not correct. Procedural macros can be invoked in three forms, as per the Rust Reference:
Procedural macros allow creating syntax extensions as execution of a function. Procedural macros come in one of three flavors:
- Function-like macros -
custom!(...)- Derive macros -
#[derive(CustomDerive)]- Attribute macros -
#[CustomAttribute]
None of these three forms allow arbitrary multi-token-tree parsing.
- Function-like macros receive the contents of one set of brackets — just like
macro_rules!macros. - Derive and attribute macros receive one item definition, which must still match the Rust grammar for items.
It would certainly be useful for macro_rules! to be usable in derive and attribute position (see Declarative `macro_rules!` attribute macros by joshtriplett · Pull Request #3697 · rust-lang/rfcs · GitHub, Declarative `macro_rules!` derive macros by joshtriplett · Pull Request #3698 · rust-lang/rfcs · GitHub, macro_rules_attribute) but that’s not the same as parsing arbitrary syntax outside of brackets.