Commit Graph

3 Commits

Author SHA1 Message Date
Nicholas Nethercote
347cd4e6cb Augment the test.
Some cases that are currently handled incorrectly.
2025-08-08 14:04:17 +10:00
Nicholas Nethercote
25a6fd3213 Augment the macro-stats test.
With a long macro name that could fit on one line, but currently isn't
formatted that way, because the name would overlap with the maximum
width of the "Uses" column. (The next commit will fix this.)
2025-06-30 12:53:00 +10:00
Nicholas Nethercote
376cbc3787 Introduce -Zmacro-stats.
It collects data about macro expansions and prints them in a table after
expansion finishes. It's very useful for detecting macro bloat,
especially for proc macros.

Details:
- It measures code snippets by pretty-printing them and then measuring
  lines and bytes. This required a bunch of additional pretty-printing
  plumbing, in `rustc_ast_pretty` and `rustc_expand`.
- The measurement is done in `MacroExpander::expand_invoc`.
- The measurements are stored in `ExtCtxt::macro_stats`.
2025-06-12 21:17:17 +10:00