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`.
This commit is contained in:
@@ -2305,6 +2305,8 @@ options! {
|
||||
(space separated)"),
|
||||
macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
|
||||
"show macro backtraces (default: no)"),
|
||||
macro_stats: bool = (false, parse_bool, [UNTRACKED],
|
||||
"print some statistics about macro expansions (default: no)"),
|
||||
maximal_hir_to_mir_coverage: bool = (false, parse_bool, [TRACKED],
|
||||
"save as much information as possible about the correspondence between MIR and HIR \
|
||||
as source scopes (default: no)"),
|
||||
|
||||
Reference in New Issue
Block a user