@@ -341,20 +341,30 @@ fn print_macro_stats(ecx: &ExtCtxt<'_>) {
341341    } 
342342    for  ( bytes,  lines,  uses,  name,  kind)  in  macro_stats { 
343343        let  mut  name = ExpnKind :: Macro ( kind,  * name) . descr ( ) ; 
344+         let  uses_with_underscores = thousands:: usize_with_underscores ( uses) ; 
344345        let  avg_lines = lines as  f64  / uses as  f64 ; 
345346        let  avg_bytes = bytes as  f64  / uses as  f64 ; 
346-         if  name. len ( )  >= name_w { 
347-             // If the name is long, print it on a line by itself, then 
348-             // set the name to empty and print things normally, to show the 
349-             // stats on the next line. 
347+ 
348+         // Ensure the "Macro Name" and "Uses" columns are as compact as possible. 
349+         let  mut  uses_w = uses_w; 
350+         if  name. len ( )  + uses_with_underscores. len ( )  >= name_w + uses_w { 
351+             // The name would abut or overlap the uses value. Print the name 
352+             // on a line by itself, then set the name to empty and print things 
353+             // normally, to show the stats on the next line. 
350354            _ = writeln ! ( s,  "{prefix} {:<name_w$}" ,  name) ; 
351355            name = String :: new ( ) ; 
352-         } 
356+         }  else  if  name. len ( )  >= name_w { 
357+             // The name won't abut or overlap with the uses value, but it does 
358+             // overlap with the empty part of the uses column. Shrink the width 
359+             // of the uses column to account for the excess name length. 
360+             uses_w = uses_with_underscores. len ( )  + 1 
361+         } ; 
362+ 
353363        _ = writeln ! ( 
354364            s, 
355365            "{prefix} {:<name_w$}{:>uses_w$}{:>lines_w$}{:>avg_lines_w$}{:>bytes_w$}{:>avg_bytes_w$}" , 
356366            name, 
357-             thousands :: usize_with_underscores ( uses ) , 
367+             uses_with_underscores , 
358368            thousands:: usize_with_underscores( lines) , 
359369            thousands:: f64p1_with_underscores( avg_lines) , 
360370            thousands:: usize_with_underscores( bytes) , 
0 commit comments