Macro expansion is the source or language construct produced when Rust evaluates a macro invocation. A macro can match recursive token trees, repeat arguments, and pass them into another macro. section 5.1.2
In a variadic `special_println!`, `$($arg:tt)*` captures any number of token-tree arguments, while `$($arg)*` transcribes them into `println!` or `format!`. Expansions can therefore nest and call other macros. section 5.1.2
Tracing nested expansion
Enabling `trace_macros!` around `special_println!("hello world!")` reveals successive expansions through `special_println!`, `println!`, `format!`, and the compiler-built-in `format_args!`. section 5.1.2
note: trace_macro
--> src/main.rs:84:5
|
84 | special_println!("hello world!");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expanding `special_println! { "hello world!" }`
= note: to `println! ("Printed specially: {}", format! ("hello world!"))`
= note: expanding `println! { "Printed specially: {}", format!
("hello world!") }`
= note: to `{
$crate :: io ::
_print($crate :: format_args_nl!
("Printed specially: {}", format! ("hello world!"))) ;
}`
= note: expanding `format! { "hello world!" }`
= note: to `{
let res = $crate :: fmt ::
format($crate :: __export :: format_args! ("hello world!")) ; res
}`
Inspect the compiler-style expansion trace to follow how one macro invocation becomes nested generated constructs. section 5.1.2



