@@ -657,24 +657,30 @@ Available lint options:
657
657
658
658
fn describe_debug_flags ( ) {
659
659
println ! ( "\n Available debug options:\n " ) ;
660
- for & ( name, _, opt_type_desc, desc) in config:: DB_OPTIONS {
661
- let ( width, extra) = match opt_type_desc {
662
- Some ( ..) => ( 21 , "=val" ) ,
663
- None => ( 25 , "" )
664
- } ;
665
- println ! ( " -Z {:>width$}{} -- {}" , name. replace( "_" , "-" ) ,
666
- extra, desc, width=width) ;
667
- }
660
+ print_flag_list ( "-Z" , config:: DB_OPTIONS ) ;
668
661
}
669
662
670
663
fn describe_codegen_flags ( ) {
671
664
println ! ( "\n Available codegen options:\n " ) ;
672
- for & ( name, _, opt_type_desc, desc) in config:: CG_OPTIONS {
665
+ print_flag_list ( "-C" , config:: CG_OPTIONS ) ;
666
+ }
667
+
668
+ fn print_flag_list < T > ( cmdline_opt : & str ,
669
+ flag_list : & [ ( & ' static str , T , Option < & ' static str > , & ' static str ) ] ) {
670
+ let max_len = flag_list. iter ( ) . map ( |& ( name, _, opt_type_desc, _) | {
671
+ let extra_len = match opt_type_desc {
672
+ Some ( ..) => 4 ,
673
+ None => 0
674
+ } ;
675
+ name. chars ( ) . count ( ) + extra_len
676
+ } ) . max ( ) . unwrap_or ( 0 ) ;
677
+
678
+ for & ( name, _, opt_type_desc, desc) in flag_list {
673
679
let ( width, extra) = match opt_type_desc {
674
- Some ( ..) => ( 21 , "=val" ) ,
675
- None => ( 25 , "" )
680
+ Some ( ..) => ( max_len - 4 , "=val" ) ,
681
+ None => ( max_len , "" )
676
682
} ;
677
- println ! ( " -C {:>width$}{} -- {}" , name. replace( "_" , "-" ) ,
683
+ println ! ( " {} {:>width$}{} -- {}" , cmdline_opt , name. replace( "_" , "-" ) ,
678
684
extra, desc, width=width) ;
679
685
}
680
686
}
0 commit comments