Use RUSTFLAGS="-Z macro-backtrace" to view expanded proc macro code and debug compilation errors.
Enable verbose macro expansion to see the generated code and pinpoint syntax errors in your proc macro logic.
RUSTFLAGS="-Z macro-backtrace" cargo build
This flag forces the compiler to print the expanded macro output and includes a backtrace showing exactly where the macro expansion failed.
Proc macros generate code before your program compiles, so errors often look confusing because they point to the generated code, not your source. This command tells the compiler to show you the actual code your macro created, making it easy to see if the macro is producing invalid syntax or logic.