diff options
| author | bors <bors@rust-lang.org> | 2015-11-07 23:45:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-11-07 23:45:14 +0000 |
| commit | bfdc358910e2c3287a8147f55221d2e6c9a92c8f (patch) | |
| tree | 5aa207b1df57934f146ddd06336468363956a6a0 | |
| parent | 43b5d5e0de1dbbe655160915cc9a7bb56a68d86c (diff) | |
| parent | 61bb652ada182fece755710c40e9631594315d1e (diff) | |
| download | rust-bfdc358910e2c3287a8147f55221d2e6c9a92c8f.tar.gz rust-bfdc358910e2c3287a8147f55221d2e6c9a92c8f.zip | |
Auto merge of #29674 - inrustwetrust:flag_alignment, r=alexcrichton
The `enable-nonzeroing-move-hints` flag name was too long and caused misalignment of the help text. Now calculating the needed padding dynamically from the available flags instead.
| -rw-r--r-- | src/librustc_driver/lib.rs | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index ce40d9b53ff..d50b8e5eca2 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -657,24 +657,30 @@ Available lint options: fn describe_debug_flags() { println!("\nAvailable debug options:\n"); - for &(name, _, opt_type_desc, desc) in config::DB_OPTIONS { - let (width, extra) = match opt_type_desc { - Some(..) => (21, "=val"), - None => (25, "") - }; - println!(" -Z {:>width$}{} -- {}", name.replace("_", "-"), - extra, desc, width=width); - } + print_flag_list("-Z", config::DB_OPTIONS); } fn describe_codegen_flags() { println!("\nAvailable codegen options:\n"); - for &(name, _, opt_type_desc, desc) in config::CG_OPTIONS { + print_flag_list("-C", config::CG_OPTIONS); +} + +fn print_flag_list<T>(cmdline_opt: &str, + flag_list: &[(&'static str, T, Option<&'static str>, &'static str)]) { + let max_len = flag_list.iter().map(|&(name, _, opt_type_desc, _)| { + let extra_len = match opt_type_desc { + Some(..) => 4, + None => 0 + }; + name.chars().count() + extra_len + }).max().unwrap_or(0); + + for &(name, _, opt_type_desc, desc) in flag_list { let (width, extra) = match opt_type_desc { - Some(..) => (21, "=val"), - None => (25, "") + Some(..) => (max_len - 4, "=val"), + None => (max_len, "") }; - println!(" -C {:>width$}{} -- {}", name.replace("_", "-"), + println!(" {} {:>width$}{} -- {}", cmdline_opt, name.replace("_", "-"), extra, desc, width=width); } } |
