Skip to content

Commit 8b4701d

Browse files
committed
Remove rustc_session::config::rustc_short_optgroups
1 parent 3250c1c commit 8b4701d

2 files changed

Lines changed: 29 additions & 27 deletions

File tree

‎compiler/rustc_driver_impl/src/lib.rs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,9 +934,12 @@ pub fn version_at_macro_invocation(
934934
}
935935

936936
fn usage(verbose:bool, include_unstable_options:bool, nightly_build:bool){
937-
let groups = if verbose { config::rustc_optgroups()} else { config::rustc_short_optgroups()};
938937
letmut options = getopts::Options::new();
939-
for option in groups.iter().filter(|x| include_unstable_options || x.is_stable()){
938+
for option in config::rustc_optgroups()
939+
.iter()
940+
.filter(|x| verbose || !x.is_verbose_help_only)
941+
.filter(|x| include_unstable_options || x.is_stable())
942+
{
940943
option.apply(&mut options);
941944
}
942945
let message = "Usage: rustc [OPTIONS] INPUT";

‎compiler/rustc_session/src/config.rs‎

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,10 @@ pub struct RustcOptGroup {
14131413
long_name:&'staticstr,
14141414
desc:&'staticstr,
14151415
value_hint:&'staticstr,
1416+
1417+
/// If true, this option should not be printed by `rustc --help`, but
1418+
/// should still be printed by `rustc --help -v`.
1419+
pubis_verbose_help_only:bool,
14161420
}
14171421

14181422
implRustcOptGroup{
@@ -1452,6 +1456,7 @@ pub fn make_opt(
14521456
long_name,
14531457
desc,
14541458
value_hint,
1459+
is_verbose_help_only:false,
14551460
}
14561461
}
14571462

@@ -1462,16 +1467,15 @@ The default is {DEFAULT_EDITION} and the latest stable edition is {LATEST_STABLE
14621467
)
14631468
});
14641469

1465-
/// Returns the "short" subset of the rustc command line options,
1466-
/// including metadata for each option, such as whether the option is
1467-
/// part of the stable long-term interface for rustc.
1468-
pubfnrustc_short_optgroups() -> Vec<RustcOptGroup>{
1470+
/// Returns all rustc command line options, including metadata for
1471+
/// each option, such as whether the option is stable.
1472+
pubfnrustc_optgroups() -> Vec<RustcOptGroup>{
14691473
useOptionKind::{Flag,FlagMulti,Multi,Opt};
1470-
useOptionStability::Stable;
1474+
useOptionStability::{Stable,Unstable};
14711475

14721476
useself::make_opt as opt;
14731477

1474-
vec![
1478+
letmut options = vec![
14751479
opt(Stable,Flag,"h","help","Display this message",""),
14761480
opt(
14771481
Stable,
@@ -1558,21 +1562,11 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
15581562
opt(Stable,Multi,"C","codegen","Set a codegen option","OPT[=VALUE]"),
15591563
opt(Stable,Flag,"V","version","Print version info and exit",""),
15601564
opt(Stable,Flag,"v","verbose","Use verbose output",""),
1561-
]
1562-
}
1563-
1564-
/// Returns all rustc command line options, including metadata for
1565-
/// each option, such as whether the option is part of the stable
1566-
/// long-term interface for rustc.
1567-
pubfnrustc_optgroups() -> Vec<RustcOptGroup>{
1568-
useOptionKind::{Multi,Opt};
1569-
useOptionStability::{Stable,Unstable};
1570-
1571-
useself::make_opt as opt;
1565+
];
15721566

1573-
letmut opts = rustc_short_optgroups();
1574-
// FIXME: none of these descriptions are actually used
1575-
opts.extend(vec![
1567+
// Options in this list are hidden from `rustc --help` by default, but are
1568+
// shown by `rustc --help -v`.
1569+
let verbose_only = [
15761570
opt(
15771571
Stable,
15781572
Multi,
@@ -1598,9 +1592,9 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
15981592
"",
15991593
"color",
16001594
"Configure coloring of output:
1601-
auto = colorize, if output goes to a tty (default);
1602-
always = always colorize output;
1603-
never = never colorize output",
1595+
auto = colorize, if output goes to a tty (default);
1596+
always = always colorize output;
1597+
never = never colorize output",
16041598
"auto|always|never",
16051599
),
16061600
opt(
@@ -1620,8 +1614,13 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
16201614
"FROM=TO",
16211615
),
16221616
opt(Unstable,Multi,"","env-set","Inject an environment variable","VAR=VALUE"),
1623-
]);
1624-
opts
1617+
];
1618+
options.extend(verbose_only.into_iter().map(|mut opt| {
1619+
opt.is_verbose_help_only = true;
1620+
opt
1621+
}));
1622+
1623+
options
16251624
}
16261625

16271626
pubfnget_cmd_lint_options(

0 commit comments

Comments
 (0)