Skip to content

deprecate --help -v #22495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 5 additions & 31 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,22 +655,6 @@ pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
}
}

/// Returns the "short" subset of the stable rustc command line options.
pub fn short_optgroups() -> Vec<getopts::OptGroup> {
rustc_short_optgroups().into_iter()
.filter(|g|g.is_stable())
.map(|g|g.opt_group)
.collect()
}

/// Returns all of the stable rustc command line options.
pub fn optgroups() -> Vec<getopts::OptGroup> {
rustc_optgroups().into_iter()
.filter(|g|g.is_stable())
.map(|g|g.opt_group)
.collect()
}

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum OptionStability { Stable, Unstable }

Expand Down Expand Up @@ -730,10 +714,10 @@ mod opt {
pub fn flagopt_u(a: S, b: S, c: S, d: S) -> R { unstable(getopts::optflagopt(a, b, c, d)) }
}

/// Returns the "short" subset of the rustc command line options,
/// including metadata for each option, such as whether the option is
/// part of the stable long-term interface for rustc.
pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
/// Returns all rustc command line options, including metadata for
/// each option, such as whether the option is part of the stable
/// long-term interface for rustc.
pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
vec![
opt::flag("h", "help", "Display this message"),
opt::multi("", "cfg", "Configure the compilation environment", "SPEC"),
Expand Down Expand Up @@ -774,15 +758,6 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
opt::multi("C", "codegen", "Set a codegen option", "OPT[=VALUE]"),
opt::flag("V", "version", "Print version info and exit"),
opt::flag("v", "verbose", "Use verbose output"),
]
}

/// Returns all rustc command line options, including metadata for
/// each option, such as whether the option is part of the stable
/// long-term interface for rustc.
pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
let mut opts = rustc_short_optgroups();
opts.push_all(&[
opt::multi("", "extern", "Specify where an external rust library is \
located",
"NAME=PATH"),
Expand All @@ -807,8 +782,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
`everybody_loops` (all function bodies replaced with `loop {}`).",
"TYPE"),
opt::opt_u("", "show-span", "Show spans for compiler debugging", "expr|pat|ty"),
]);
opts
]
}

// Convert strings provided as --cfg [cfgspec] into a crate_cfg
Expand Down
23 changes: 6 additions & 17 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,29 +497,18 @@ pub fn version(binary: &str, matches: &getopts::Matches) {
}
}

fn usage(verbose: bool, include_unstable_options: bool) {
let groups = if verbose {
config::rustc_optgroups()
} else {
config::rustc_short_optgroups()
};
let groups : Vec<_> = groups.into_iter()
fn usage(include_unstable_options: bool) {
let groups : Vec<_> = config::rustc_optgroups().into_iter()
.filter(|x| include_unstable_options || x.is_stable())
.map(|x|x.opt_group)
.collect();
let message = format!("Usage: rustc [OPTIONS] INPUT");
let extra_help = if verbose {
""
} else {
"\n --help -v Print the full set of options rustc accepts"
};
println!("{}\n\
Additional help:
-C help Print codegen options
-W help Print 'lint' options and default settings
-Z help Print internal options for debugging rustc{}\n",
getopts::usage(&message, &groups),
extra_help);
-Z help Print internal options for debugging rustc\n",
getopts::usage(&message, &groups));
}

fn describe_lints(lint_store: &lint::LintStore, loaded_plugins: bool) {
Expand Down Expand Up @@ -673,7 +662,7 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
if args.is_empty() {
// user did not write `-v` nor `-Z unstable-options`, so do not
// include that extra information.
usage(false, false);
usage(false);
return None;
}

Expand Down Expand Up @@ -709,7 +698,7 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
let include_unstable_options = r.iter().any(|x| *x == "unstable-options");

if matches.opt_present("h") || matches.opt_present("help") {
usage(matches.opt_present("verbose"), include_unstable_options);
usage(include_unstable_options);
return None;
}

Expand Down