Skip to content

Commit 584c820

Browse files
committed
Use a method to apply RustcOptGroup to getopts::Options
1 parent 8f7f9b9 commit 584c820

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

Diff for: compiler/rustc_driver_impl/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ fn usage(verbose: bool, include_unstable_options: bool, nightly_build: bool) {
937937
let groups = if verbose { config::rustc_optgroups() } else { config::rustc_short_optgroups() };
938938
let mut options = getopts::Options::new();
939939
for option in groups.iter().filter(|x| include_unstable_options || x.is_stable()) {
940-
(option.apply)(&mut options);
940+
option.apply(&mut options);
941941
}
942942
let message = "Usage: rustc [OPTIONS] INPUT";
943943
let nightly_help = if nightly_build {
@@ -1219,7 +1219,7 @@ pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<geto
12191219
let mut options = getopts::Options::new();
12201220
let optgroups = config::rustc_optgroups();
12211221
for option in &optgroups {
1222-
(option.apply)(&mut options);
1222+
option.apply(&mut options);
12231223
}
12241224
let matches = options.parse(args).unwrap_or_else(|e| {
12251225
let msg: Option<String> = match e {
@@ -1233,7 +1233,7 @@ pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<geto
12331233
optgroups.iter().find(|option| option.name == opt).map(|option| {
12341234
// Print the help just for the option in question.
12351235
let mut options = getopts::Options::new();
1236-
(option.apply)(&mut options);
1236+
option.apply(&mut options);
12371237
// getopt requires us to pass a function for joining an iterator of
12381238
// strings, even though in this case we expect exactly one string.
12391239
options.usage_with_format(|it| {

Diff for: compiler/rustc_interface/src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ where
102102
fn optgroups() -> getopts::Options {
103103
let mut opts = getopts::Options::new();
104104
for group in rustc_optgroups() {
105-
(group.apply)(&mut opts);
105+
group.apply(&mut opts);
106106
}
107107
return opts;
108108
}

Diff for: compiler/rustc_session/src/config.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ enum OptionStability {
13731373
}
13741374

13751375
pub struct RustcOptGroup {
1376-
pub apply: Box<dyn Fn(&mut getopts::Options) -> &mut getopts::Options>,
1376+
apply: Box<dyn Fn(&mut getopts::Options) -> &mut getopts::Options>,
13771377
pub name: &'static str,
13781378
stability: OptionStability,
13791379
}
@@ -1383,6 +1383,10 @@ impl RustcOptGroup {
13831383
self.stability == OptionStability::Stable
13841384
}
13851385

1386+
pub fn apply(&self, options: &mut getopts::Options) {
1387+
(self.apply)(options);
1388+
}
1389+
13861390
pub fn stable<F>(name: &'static str, f: F) -> RustcOptGroup
13871391
where
13881392
F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static,

Diff for: src/librustdoc/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ fn opts() -> Vec<RustcOptGroup> {
685685
fn usage(argv0: &str) {
686686
let mut options = getopts::Options::new();
687687
for option in opts() {
688-
(option.apply)(&mut options);
688+
option.apply(&mut options);
689689
}
690690
println!("{}", options.usage(&format!("{argv0} [options] <input>")));
691691
println!(" @path Read newline separated options from `path`\n");
@@ -769,7 +769,7 @@ fn main_args(
769769

770770
let mut options = getopts::Options::new();
771771
for option in opts() {
772-
(option.apply)(&mut options);
772+
option.apply(&mut options);
773773
}
774774
let matches = match options.parse(&args) {
775775
Ok(m) => m,

0 commit comments

Comments
 (0)