Skip to content

Commit c4884bb

Browse files
committed
Support having -Z and -C options with the same name
Tweak the `options!` macro to allow for -Z and -C options with the same name without generating conflicting internal parsing functions. Split out of the commit stabilizing -Z strip as -C strip.
1 parent 4205481 commit c4884bb

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

compiler/rustc_session/src/options.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ top_level_options!(
219219
/// generated code to parse an option into its respective field in the struct. There are a few
220220
/// hand-written parsers for parsing specific types of values in this module.
221221
macro_rules! options {
222-
($struct_name:ident, $stat:ident, $prefix:expr, $outputname:expr,
222+
($struct_name:ident, $stat:ident, $optmod:ident, $prefix:expr, $outputname:expr,
223223
$($( #[$attr:meta] )* $opt:ident : $t:ty = (
224224
$init:expr,
225225
$parse:ident,
@@ -264,13 +264,15 @@ macro_rules! options {
264264
}
265265

266266
pub const $stat: OptionDescrs<$struct_name> =
267-
&[ $( (stringify!($opt), $opt, desc::$parse, $desc) ),* ];
267+
&[ $( (stringify!($opt), $optmod::$opt, desc::$parse, $desc) ),* ];
268268

269+
mod $optmod {
269270
$(
270-
fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
271-
parse::$parse(&mut redirect_field!(cg.$opt), v)
271+
pub(super) fn $opt(cg: &mut super::$struct_name, v: Option<&str>) -> bool {
272+
super::parse::$parse(&mut redirect_field!(cg.$opt), v)
272273
}
273274
)*
275+
}
274276

275277
) }
276278

@@ -918,7 +920,7 @@ mod parse {
918920
}
919921

920922
options! {
921-
CodegenOptions, CG_OPTIONS, "C", "codegen",
923+
CodegenOptions, CG_OPTIONS, cgopts, "C", "codegen",
922924

923925
// This list is in alphabetical order.
924926
//
@@ -1027,7 +1029,7 @@ options! {
10271029
}
10281030

10291031
options! {
1030-
DebuggingOptions, DB_OPTIONS, "Z", "debugging",
1032+
DebuggingOptions, DB_OPTIONS, dbopts, "Z", "debugging",
10311033

10321034
// This list is in alphabetical order.
10331035
//

0 commit comments

Comments
 (0)