Skip to content

Commit e4d6ff5

Browse files
committed
Remove rustc_session::config::rustc_short_optgroups
1 parent 18da964 commit e4d6ff5

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

compiler/rustc_driver_impl/src/lib.rs

+5-2
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
let mut 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

+24-25
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,10 @@ pub struct RustcOptGroup {
14081408
long_name: &'static str,
14091409
desc: &'static str,
14101410
value_hint: &'static str,
1411+
1412+
/// If true, this option should not be printed by `rustc --help`, but
1413+
/// should still be printed by `rustc --help -v`.
1414+
pub is_verbose_help_only: bool,
14111415
}
14121416

14131417
impl RustcOptGroup {
@@ -1447,6 +1451,7 @@ pub fn make_opt(
14471451
long_name,
14481452
desc,
14491453
value_hint,
1454+
is_verbose_help_only: false,
14501455
}
14511456
}
14521457

@@ -1457,16 +1462,15 @@ The default is {DEFAULT_EDITION} and the latest stable edition is {LATEST_STABLE
14571462
)
14581463
});
14591464

1460-
/// Returns the "short" subset of the rustc command line options,
1461-
/// including metadata for each option, such as whether the option is
1462-
/// part of the stable long-term interface for rustc.
1463-
pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
1465+
/// Returns all rustc command line options, including metadata for
1466+
/// each option, such as whether the option is stable.
1467+
pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
14641468
use OptionKind::{Flag, FlagMulti, Multi, Opt};
1465-
use OptionStability::Stable;
1469+
use OptionStability::{Stable, Unstable};
14661470

14671471
use self::make_opt as opt;
14681472

1469-
vec![
1473+
let mut options = vec![
14701474
opt(Stable, Flag, "h", "help", "Display this message", ""),
14711475
opt(
14721476
Stable,
@@ -1553,21 +1557,11 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
15531557
opt(Stable, Multi, "C", "codegen", "Set a codegen option", "OPT[=VALUE]"),
15541558
opt(Stable, Flag, "V", "version", "Print version info and exit", ""),
15551559
opt(Stable, Flag, "v", "verbose", "Use verbose output", ""),
1556-
]
1557-
}
1558-
1559-
/// Returns all rustc command line options, including metadata for
1560-
/// each option, such as whether the option is part of the stable
1561-
/// long-term interface for rustc.
1562-
pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
1563-
use OptionKind::{Multi, Opt};
1564-
use OptionStability::{Stable, Unstable};
1565-
1566-
use self::make_opt as opt;
1560+
];
15671561

1568-
let mut opts = rustc_short_optgroups();
1569-
// FIXME: none of these descriptions are actually used
1570-
opts.extend(vec![
1562+
// Options in this list are hidden from `rustc --help` by default, but are
1563+
// shown by `rustc --help -v`.
1564+
let verbose_only = [
15711565
opt(
15721566
Stable,
15731567
Multi,
@@ -1593,9 +1587,9 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
15931587
"",
15941588
"color",
15951589
"Configure coloring of output:
1596-
auto = colorize, if output goes to a tty (default);
1597-
always = always colorize output;
1598-
never = never colorize output",
1590+
auto = colorize, if output goes to a tty (default);
1591+
always = always colorize output;
1592+
never = never colorize output",
15991593
"auto|always|never",
16001594
),
16011595
opt(
@@ -1615,8 +1609,13 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
16151609
"FROM=TO",
16161610
),
16171611
opt(Unstable, Multi, "", "env-set", "Inject an environment variable", "VAR=VALUE"),
1618-
]);
1619-
opts
1612+
];
1613+
options.extend(verbose_only.into_iter().map(|mut opt| {
1614+
opt.is_verbose_help_only = true;
1615+
opt
1616+
}));
1617+
1618+
options
16201619
}
16211620

16221621
pub fn get_cmd_lint_options(

0 commit comments

Comments
 (0)