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.
This commit is contained in:
parent
4205481110
commit
c4884bbec7
1 changed files with 8 additions and 6 deletions
|
@ -219,7 +219,7 @@ top_level_options!(
|
||||||
/// generated code to parse an option into its respective field in the struct. There are a few
|
/// generated code to parse an option into its respective field in the struct. There are a few
|
||||||
/// hand-written parsers for parsing specific types of values in this module.
|
/// hand-written parsers for parsing specific types of values in this module.
|
||||||
macro_rules! options {
|
macro_rules! options {
|
||||||
($struct_name:ident, $stat:ident, $prefix:expr, $outputname:expr,
|
($struct_name:ident, $stat:ident, $optmod:ident, $prefix:expr, $outputname:expr,
|
||||||
$($( #[$attr:meta] )* $opt:ident : $t:ty = (
|
$($( #[$attr:meta] )* $opt:ident : $t:ty = (
|
||||||
$init:expr,
|
$init:expr,
|
||||||
$parse:ident,
|
$parse:ident,
|
||||||
|
@ -264,13 +264,15 @@ macro_rules! options {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const $stat: OptionDescrs<$struct_name> =
|
pub const $stat: OptionDescrs<$struct_name> =
|
||||||
&[ $( (stringify!($opt), $opt, desc::$parse, $desc) ),* ];
|
&[ $( (stringify!($opt), $optmod::$opt, desc::$parse, $desc) ),* ];
|
||||||
|
|
||||||
|
mod $optmod {
|
||||||
$(
|
$(
|
||||||
fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
|
pub(super) fn $opt(cg: &mut super::$struct_name, v: Option<&str>) -> bool {
|
||||||
parse::$parse(&mut redirect_field!(cg.$opt), v)
|
super::parse::$parse(&mut redirect_field!(cg.$opt), v)
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
|
}
|
||||||
|
|
||||||
) }
|
) }
|
||||||
|
|
||||||
|
@ -918,7 +920,7 @@ mod parse {
|
||||||
}
|
}
|
||||||
|
|
||||||
options! {
|
options! {
|
||||||
CodegenOptions, CG_OPTIONS, "C", "codegen",
|
CodegenOptions, CG_OPTIONS, cgopts, "C", "codegen",
|
||||||
|
|
||||||
// This list is in alphabetical order.
|
// This list is in alphabetical order.
|
||||||
//
|
//
|
||||||
|
@ -1027,7 +1029,7 @@ options! {
|
||||||
}
|
}
|
||||||
|
|
||||||
options! {
|
options! {
|
||||||
DebuggingOptions, DB_OPTIONS, "Z", "debugging",
|
DebuggingOptions, DB_OPTIONS, dbopts, "Z", "debugging",
|
||||||
|
|
||||||
// This list is in alphabetical order.
|
// This list is in alphabetical order.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue