mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Use a method to apply RustcOptGroup
to getopts::Options
This commit is contained in:
parent
8f7f9b93b2
commit
584c8200de
@ -937,7 +937,7 @@ fn usage(verbose: bool, include_unstable_options: bool, nightly_build: bool) {
|
||||
let groups = if verbose { config::rustc_optgroups() } else { config::rustc_short_optgroups() };
|
||||
let mut options = getopts::Options::new();
|
||||
for option in groups.iter().filter(|x| include_unstable_options || x.is_stable()) {
|
||||
(option.apply)(&mut options);
|
||||
option.apply(&mut options);
|
||||
}
|
||||
let message = "Usage: rustc [OPTIONS] INPUT";
|
||||
let nightly_help = if nightly_build {
|
||||
@ -1219,7 +1219,7 @@ pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<geto
|
||||
let mut options = getopts::Options::new();
|
||||
let optgroups = config::rustc_optgroups();
|
||||
for option in &optgroups {
|
||||
(option.apply)(&mut options);
|
||||
option.apply(&mut options);
|
||||
}
|
||||
let matches = options.parse(args).unwrap_or_else(|e| {
|
||||
let msg: Option<String> = match e {
|
||||
@ -1233,7 +1233,7 @@ pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<geto
|
||||
optgroups.iter().find(|option| option.name == opt).map(|option| {
|
||||
// Print the help just for the option in question.
|
||||
let mut options = getopts::Options::new();
|
||||
(option.apply)(&mut options);
|
||||
option.apply(&mut options);
|
||||
// getopt requires us to pass a function for joining an iterator of
|
||||
// strings, even though in this case we expect exactly one string.
|
||||
options.usage_with_format(|it| {
|
||||
|
@ -102,7 +102,7 @@ where
|
||||
fn optgroups() -> getopts::Options {
|
||||
let mut opts = getopts::Options::new();
|
||||
for group in rustc_optgroups() {
|
||||
(group.apply)(&mut opts);
|
||||
group.apply(&mut opts);
|
||||
}
|
||||
return opts;
|
||||
}
|
||||
|
@ -1373,7 +1373,7 @@ enum OptionStability {
|
||||
}
|
||||
|
||||
pub struct RustcOptGroup {
|
||||
pub apply: Box<dyn Fn(&mut getopts::Options) -> &mut getopts::Options>,
|
||||
apply: Box<dyn Fn(&mut getopts::Options) -> &mut getopts::Options>,
|
||||
pub name: &'static str,
|
||||
stability: OptionStability,
|
||||
}
|
||||
@ -1383,6 +1383,10 @@ impl RustcOptGroup {
|
||||
self.stability == OptionStability::Stable
|
||||
}
|
||||
|
||||
pub fn apply(&self, options: &mut getopts::Options) {
|
||||
(self.apply)(options);
|
||||
}
|
||||
|
||||
pub fn stable<F>(name: &'static str, f: F) -> RustcOptGroup
|
||||
where
|
||||
F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static,
|
||||
|
@ -685,7 +685,7 @@ fn opts() -> Vec<RustcOptGroup> {
|
||||
fn usage(argv0: &str) {
|
||||
let mut options = getopts::Options::new();
|
||||
for option in opts() {
|
||||
(option.apply)(&mut options);
|
||||
option.apply(&mut options);
|
||||
}
|
||||
println!("{}", options.usage(&format!("{argv0} [options] <input>")));
|
||||
println!(" @path Read newline separated options from `path`\n");
|
||||
@ -769,7 +769,7 @@ fn main_args(
|
||||
|
||||
let mut options = getopts::Options::new();
|
||||
for option in opts() {
|
||||
(option.apply)(&mut options);
|
||||
option.apply(&mut options);
|
||||
}
|
||||
let matches = match options.parse(&args) {
|
||||
Ok(m) => m,
|
||||
|
Loading…
Reference in New Issue
Block a user