Auto merge of #84802 - jyn514:option-dead-code, r=Mark-Simulacrum
Remove dead code in `rustc_session::Options` - Don't recompile the same functions for each debugging option This reduces the amount of items in the crate by quite a lot. - Remove unused `parse_opt_list` and `parse_pathbuf_push` functions - Remove unused macro parameters - Remove `allow(dead_code)`.
This commit is contained in:
commit
89ebad52a8
1 changed files with 557 additions and 533 deletions
|
@ -212,7 +212,7 @@ top_level_options!(
|
||||||
macro_rules! options {
|
macro_rules! options {
|
||||||
($struct_name:ident, $setter_name:ident, $defaultfn:ident,
|
($struct_name:ident, $setter_name:ident, $defaultfn:ident,
|
||||||
$buildfn:ident, $prefix:expr, $outputname:expr,
|
$buildfn:ident, $prefix:expr, $outputname:expr,
|
||||||
$stat:ident, $mod_desc:ident, $mod_set:ident,
|
$stat:ident,
|
||||||
$($( #[$attr:meta] )* $opt:ident : $t:ty = (
|
$($( #[$attr:meta] )* $opt:ident : $t:ty = (
|
||||||
$init:expr,
|
$init:expr,
|
||||||
$parse:ident,
|
$parse:ident,
|
||||||
|
@ -286,10 +286,26 @@ macro_rules! options {
|
||||||
|
|
||||||
pub type $setter_name = fn(&mut $struct_name, v: Option<&str>) -> bool;
|
pub type $setter_name = fn(&mut $struct_name, v: Option<&str>) -> bool;
|
||||||
pub const $stat: &[(&str, $setter_name, &str, &str)] =
|
pub const $stat: &[(&str, $setter_name, &str, &str)] =
|
||||||
&[ $( (stringify!($opt), $mod_set::$opt, $mod_desc::$parse, $desc) ),* ];
|
&[ $( (stringify!($opt), crate::options::parse::$opt, $crate::options::desc::$parse, $desc) ),* ];
|
||||||
|
|
||||||
#[allow(non_upper_case_globals, dead_code)]
|
// Sometimes different options need to build a common structure.
|
||||||
mod $mod_desc {
|
// That structure can kept in one of the options' fields, the others become dummy.
|
||||||
|
macro_rules! redirect_field {
|
||||||
|
($cg:ident.link_arg) => { $cg.link_args };
|
||||||
|
($cg:ident.pre_link_arg) => { $cg.pre_link_args };
|
||||||
|
($cg:ident.$field:ident) => { $cg.$field };
|
||||||
|
}
|
||||||
|
|
||||||
|
$(
|
||||||
|
pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
|
||||||
|
$crate::options::parse::$parse(&mut redirect_field!(cg.$opt), v)
|
||||||
|
}
|
||||||
|
)*
|
||||||
|
|
||||||
|
) }
|
||||||
|
|
||||||
|
#[allow(non_upper_case_globals)]
|
||||||
|
mod desc {
|
||||||
pub const parse_no_flag: &str = "no value";
|
pub const parse_no_flag: &str = "no value";
|
||||||
pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
|
pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
|
||||||
pub const parse_opt_bool: &str = parse_bool;
|
pub const parse_opt_bool: &str = parse_bool;
|
||||||
|
@ -297,9 +313,7 @@ macro_rules! options {
|
||||||
pub const parse_opt_string: &str = parse_string;
|
pub const parse_opt_string: &str = parse_string;
|
||||||
pub const parse_string_push: &str = parse_string;
|
pub const parse_string_push: &str = parse_string;
|
||||||
pub const parse_opt_pathbuf: &str = "a path";
|
pub const parse_opt_pathbuf: &str = "a path";
|
||||||
pub const parse_pathbuf_push: &str = parse_opt_pathbuf;
|
|
||||||
pub const parse_list: &str = "a space-separated list of strings";
|
pub const parse_list: &str = "a space-separated list of strings";
|
||||||
pub const parse_opt_list: &str = parse_list;
|
|
||||||
pub const parse_opt_comma_list: &str = "a comma-separated list of strings";
|
pub const parse_opt_comma_list: &str = "a comma-separated list of strings";
|
||||||
pub const parse_number: &str = "a number";
|
pub const parse_number: &str = "a number";
|
||||||
pub const parse_opt_number: &str = parse_number;
|
pub const parse_opt_number: &str = parse_number;
|
||||||
|
@ -307,7 +321,8 @@ macro_rules! options {
|
||||||
pub const parse_passes: &str = "a space-separated list of passes, or `all`";
|
pub const parse_passes: &str = "a space-separated list of passes, or `all`";
|
||||||
pub const parse_panic_strategy: &str = "either `unwind` or `abort`";
|
pub const parse_panic_strategy: &str = "either `unwind` or `abort`";
|
||||||
pub const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
|
pub const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
|
||||||
pub const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `hwaddress`, `leak`, `memory` or `thread`";
|
pub const parse_sanitizers: &str =
|
||||||
|
"comma separated list of sanitizers: `address`, `hwaddress`, `leak`, `memory` or `thread`";
|
||||||
pub const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
|
pub const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
|
||||||
pub const parse_cfguard: &str =
|
pub const parse_cfguard: &str =
|
||||||
"either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
|
"either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
|
||||||
|
@ -315,7 +330,8 @@ macro_rules! options {
|
||||||
pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavor::one_of();
|
pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavor::one_of();
|
||||||
pub const parse_optimization_fuel: &str = "crate=integer";
|
pub const parse_optimization_fuel: &str = "crate=integer";
|
||||||
pub const parse_mir_spanview: &str = "`statement` (default), `terminator`, or `block`";
|
pub const parse_mir_spanview: &str = "`statement` (default), `terminator`, or `block`";
|
||||||
pub const parse_instrument_coverage: &str = "`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`";
|
pub const parse_instrument_coverage: &str =
|
||||||
|
"`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`";
|
||||||
pub const parse_unpretty: &str = "`string` or `string=string`";
|
pub const parse_unpretty: &str = "`string` or `string=string`";
|
||||||
pub const parse_treat_err_as_bug: &str = "either no value or a number bigger than 0";
|
pub const parse_treat_err_as_bug: &str = "either no value or a number bigger than 0";
|
||||||
pub const parse_lto: &str =
|
pub const parse_lto: &str =
|
||||||
|
@ -329,49 +345,41 @@ macro_rules! options {
|
||||||
pub const parse_src_file_hash: &str = "either `md5` or `sha1`";
|
pub const parse_src_file_hash: &str = "either `md5` or `sha1`";
|
||||||
pub const parse_relocation_model: &str =
|
pub const parse_relocation_model: &str =
|
||||||
"one of supported relocation models (`rustc --print relocation-models`)";
|
"one of supported relocation models (`rustc --print relocation-models`)";
|
||||||
pub const parse_code_model: &str =
|
pub const parse_code_model: &str = "one of supported code models (`rustc --print code-models`)";
|
||||||
"one of supported code models (`rustc --print code-models`)";
|
pub const parse_tls_model: &str = "one of supported TLS models (`rustc --print tls-models`)";
|
||||||
pub const parse_tls_model: &str =
|
|
||||||
"one of supported TLS models (`rustc --print tls-models`)";
|
|
||||||
pub const parse_target_feature: &str = parse_string;
|
pub const parse_target_feature: &str = parse_string;
|
||||||
pub const parse_wasi_exec_model: &str = "either `command` or `reactor`";
|
pub const parse_wasi_exec_model: &str = "either `command` or `reactor`";
|
||||||
pub const parse_split_debuginfo: &str =
|
pub const parse_split_debuginfo: &str =
|
||||||
"one of supported split-debuginfo modes (`off` or `dsymutil`)";
|
"one of supported split-debuginfo modes (`off` or `dsymutil`)";
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
mod parse {
|
||||||
mod $mod_set {
|
crate use super::*;
|
||||||
use super::*;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
// Sometimes different options need to build a common structure.
|
|
||||||
// That structure can kept in one of the options' fields, the others become dummy.
|
|
||||||
macro_rules! redirect_field {
|
|
||||||
($cg:ident.link_arg) => { $cg.link_args };
|
|
||||||
($cg:ident.pre_link_arg) => { $cg.pre_link_args };
|
|
||||||
($cg:ident.$field:ident) => { $cg.$field };
|
|
||||||
}
|
|
||||||
|
|
||||||
$(
|
|
||||||
pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
|
|
||||||
$parse(&mut redirect_field!(cg.$opt), v)
|
|
||||||
}
|
|
||||||
)*
|
|
||||||
|
|
||||||
/// This is for boolean options that don't take a value and start with
|
/// This is for boolean options that don't take a value and start with
|
||||||
/// `no-`. This style of option is deprecated.
|
/// `no-`. This style of option is deprecated.
|
||||||
fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool {
|
crate fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
None => { *slot = true; true }
|
None => {
|
||||||
|
*slot = true;
|
||||||
|
true
|
||||||
|
}
|
||||||
Some(_) => false,
|
Some(_) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use this for any boolean option that has a static default.
|
/// Use this for any boolean option that has a static default.
|
||||||
fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
|
crate fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some("y") | Some("yes") | Some("on") | None => { *slot = true; true }
|
Some("y") | Some("yes") | Some("on") | None => {
|
||||||
Some("n") | Some("no") | Some("off") => { *slot = false; true }
|
*slot = true;
|
||||||
|
true
|
||||||
|
}
|
||||||
|
Some("n") | Some("no") | Some("off") => {
|
||||||
|
*slot = false;
|
||||||
|
true
|
||||||
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -379,111 +387,121 @@ macro_rules! options {
|
||||||
/// Use this for any boolean option that lacks a static default. (The
|
/// Use this for any boolean option that lacks a static default. (The
|
||||||
/// actions taken when such an option is not specified will depend on
|
/// actions taken when such an option is not specified will depend on
|
||||||
/// other factors, such as other options, or target options.)
|
/// other factors, such as other options, or target options.)
|
||||||
fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
|
crate fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some("y") | Some("yes") | Some("on") | None => { *slot = Some(true); true }
|
Some("y") | Some("yes") | Some("on") | None => {
|
||||||
Some("n") | Some("no") | Some("off") => { *slot = Some(false); true }
|
*slot = Some(true);
|
||||||
|
true
|
||||||
|
}
|
||||||
|
Some("n") | Some("no") | Some("off") => {
|
||||||
|
*slot = Some(false);
|
||||||
|
true
|
||||||
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use this for any string option that has a static default.
|
/// Use this for any string option that has a static default.
|
||||||
fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
|
crate fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some(s) => { *slot = s.to_string(); true },
|
Some(s) => {
|
||||||
|
*slot = s.to_string();
|
||||||
|
true
|
||||||
|
}
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use this for any string option that lacks a static default.
|
/// Use this for any string option that lacks a static default.
|
||||||
fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
|
crate fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some(s) => { *slot = Some(s.to_string()); true },
|
Some(s) => {
|
||||||
|
*slot = Some(s.to_string());
|
||||||
|
true
|
||||||
|
}
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_opt_pathbuf(slot: &mut Option<PathBuf>, v: Option<&str>) -> bool {
|
crate fn parse_opt_pathbuf(slot: &mut Option<PathBuf>, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some(s) => { *slot = Some(PathBuf::from(s)); true },
|
Some(s) => {
|
||||||
|
*slot = Some(PathBuf::from(s));
|
||||||
|
true
|
||||||
|
}
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_string_push(slot: &mut Vec<String>, v: Option<&str>) -> bool {
|
crate fn parse_string_push(slot: &mut Vec<String>, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some(s) => { slot.push(s.to_string()); true },
|
Some(s) => {
|
||||||
|
slot.push(s.to_string());
|
||||||
|
true
|
||||||
|
}
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_pathbuf_push(slot: &mut Vec<PathBuf>, v: Option<&str>) -> bool {
|
crate fn parse_list(slot: &mut Vec<String>, v: Option<&str>) -> bool {
|
||||||
match v {
|
|
||||||
Some(s) => { slot.push(PathBuf::from(s)); true },
|
|
||||||
None => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_list(slot: &mut Vec<String>, v: Option<&str>)
|
|
||||||
-> bool {
|
|
||||||
match v {
|
match v {
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
slot.extend(s.split_whitespace().map(|s| s.to_string()));
|
slot.extend(s.split_whitespace().map(|s| s.to_string()));
|
||||||
true
|
true
|
||||||
},
|
}
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_opt_list(slot: &mut Option<Vec<String>>, v: Option<&str>)
|
crate fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>) -> bool {
|
||||||
-> bool {
|
|
||||||
match v {
|
match v {
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
let v = s.split_whitespace().map(|s| s.to_string()).collect();
|
let mut v: Vec<_> = s.split(',').map(|s| s.to_string()).collect();
|
||||||
|
v.sort_unstable();
|
||||||
*slot = Some(v);
|
*slot = Some(v);
|
||||||
true
|
true
|
||||||
},
|
}
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>)
|
crate fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
|
||||||
-> bool {
|
|
||||||
match v {
|
|
||||||
Some(s) => {
|
|
||||||
let v = s.split(',').map(|s| s.to_string()).collect();
|
|
||||||
*slot = Some(v);
|
|
||||||
true
|
|
||||||
},
|
|
||||||
None => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
|
|
||||||
match v.and_then(|s| s.parse().ok()) {
|
match v.and_then(|s| s.parse().ok()) {
|
||||||
Some(0) => { *slot = ::num_cpus::get(); true },
|
Some(0) => {
|
||||||
Some(i) => { *slot = i; true },
|
*slot = ::num_cpus::get();
|
||||||
None => false
|
true
|
||||||
|
}
|
||||||
|
Some(i) => {
|
||||||
|
*slot = i;
|
||||||
|
true
|
||||||
|
}
|
||||||
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use this for any numeric option that has a static default.
|
/// Use this for any numeric option that has a static default.
|
||||||
fn parse_number<T: Copy + FromStr>(slot: &mut T, v: Option<&str>) -> bool {
|
crate fn parse_number<T: Copy + FromStr>(slot: &mut T, v: Option<&str>) -> bool {
|
||||||
match v.and_then(|s| s.parse().ok()) {
|
match v.and_then(|s| s.parse().ok()) {
|
||||||
Some(i) => { *slot = i; true },
|
Some(i) => {
|
||||||
None => false
|
*slot = i;
|
||||||
|
true
|
||||||
|
}
|
||||||
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use this for any numeric option that lacks a static default.
|
/// Use this for any numeric option that lacks a static default.
|
||||||
fn parse_opt_number<T: Copy + FromStr>(slot: &mut Option<T>, v: Option<&str>) -> bool {
|
crate fn parse_opt_number<T: Copy + FromStr>(slot: &mut Option<T>, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some(s) => { *slot = s.parse().ok(); slot.is_some() }
|
Some(s) => {
|
||||||
None => false
|
*slot = s.parse().ok();
|
||||||
|
slot.is_some()
|
||||||
|
}
|
||||||
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
|
crate fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some("all") => {
|
Some("all") => {
|
||||||
*slot = Passes::All;
|
*slot = Passes::All;
|
||||||
|
@ -501,29 +519,27 @@ macro_rules! options {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bool {
|
crate fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some("unwind") => *slot = Some(PanicStrategy::Unwind),
|
Some("unwind") => *slot = Some(PanicStrategy::Unwind),
|
||||||
Some("abort") => *slot = Some(PanicStrategy::Abort),
|
Some("abort") => *slot = Some(PanicStrategy::Abort),
|
||||||
_ => return false
|
_ => return false,
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
|
crate fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some(s) => {
|
Some(s) => match s.parse::<RelroLevel>() {
|
||||||
match s.parse::<RelroLevel>() {
|
|
||||||
Ok(level) => *slot = Some(level),
|
Ok(level) => *slot = Some(level),
|
||||||
_ => return false
|
_ => return false,
|
||||||
}
|
|
||||||
},
|
},
|
||||||
_ => return false
|
_ => return false,
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_sanitizers(slot: &mut SanitizerSet, v: Option<&str>) -> bool {
|
crate fn parse_sanitizers(slot: &mut SanitizerSet, v: Option<&str>) -> bool {
|
||||||
if let Some(v) = v {
|
if let Some(v) = v {
|
||||||
for s in v.split(',') {
|
for s in v.split(',') {
|
||||||
*slot |= match s {
|
*slot |= match s {
|
||||||
|
@ -541,16 +557,25 @@ macro_rules! options {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_sanitizer_memory_track_origins(slot: &mut usize, v: Option<&str>) -> bool {
|
crate fn parse_sanitizer_memory_track_origins(slot: &mut usize, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some("2") | None => { *slot = 2; true }
|
Some("2") | None => {
|
||||||
Some("1") => { *slot = 1; true }
|
*slot = 2;
|
||||||
Some("0") => { *slot = 0; true }
|
true
|
||||||
|
}
|
||||||
|
Some("1") => {
|
||||||
|
*slot = 1;
|
||||||
|
true
|
||||||
|
}
|
||||||
|
Some("0") => {
|
||||||
|
*slot = 0;
|
||||||
|
true
|
||||||
|
}
|
||||||
Some(_) => false,
|
Some(_) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_strip(slot: &mut Strip, v: Option<&str>) -> bool {
|
crate fn parse_strip(slot: &mut Strip, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some("none") => *slot = Strip::None,
|
Some("none") => *slot = Strip::None,
|
||||||
Some("debuginfo") => *slot = Strip::Debuginfo,
|
Some("debuginfo") => *slot = Strip::Debuginfo,
|
||||||
|
@ -560,16 +585,12 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_cfguard(slot: &mut CFGuard, v: Option<&str>) -> bool {
|
crate fn parse_cfguard(slot: &mut CFGuard, v: Option<&str>) -> bool {
|
||||||
if v.is_some() {
|
if v.is_some() {
|
||||||
let mut bool_arg = None;
|
let mut bool_arg = None;
|
||||||
if parse_opt_bool(&mut bool_arg, v) {
|
if parse_opt_bool(&mut bool_arg, v) {
|
||||||
*slot = if bool_arg.unwrap() {
|
*slot = if bool_arg.unwrap() { CFGuard::Checks } else { CFGuard::Disabled };
|
||||||
CFGuard::Checks
|
return true;
|
||||||
} else {
|
|
||||||
CFGuard::Disabled
|
|
||||||
};
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,7 +603,7 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_linker_flavor(slote: &mut Option<LinkerFlavor>, v: Option<&str>) -> bool {
|
crate fn parse_linker_flavor(slote: &mut Option<LinkerFlavor>, v: Option<&str>) -> bool {
|
||||||
match v.and_then(LinkerFlavor::from_str) {
|
match v.and_then(LinkerFlavor::from_str) {
|
||||||
Some(lf) => *slote = Some(lf),
|
Some(lf) => *slote = Some(lf),
|
||||||
_ => return false,
|
_ => return false,
|
||||||
|
@ -590,22 +611,26 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) -> bool {
|
crate fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
None => false,
|
None => false,
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
let parts = s.split('=').collect::<Vec<_>>();
|
let parts = s.split('=').collect::<Vec<_>>();
|
||||||
if parts.len() != 2 { return false; }
|
if parts.len() != 2 {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
let crate_name = parts[0].to_string();
|
let crate_name = parts[0].to_string();
|
||||||
let fuel = parts[1].parse::<u64>();
|
let fuel = parts[1].parse::<u64>();
|
||||||
if fuel.is_err() { return false; }
|
if fuel.is_err() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
*slot = Some((crate_name, fuel.unwrap()));
|
*slot = Some((crate_name, fuel.unwrap()));
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
|
crate fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
None => false,
|
None => false,
|
||||||
Some(s) if s.split('=').count() <= 2 => {
|
Some(s) if s.split('=').count() <= 2 => {
|
||||||
|
@ -616,16 +641,12 @@ macro_rules! options {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_mir_spanview(slot: &mut Option<MirSpanview>, v: Option<&str>) -> bool {
|
crate fn parse_mir_spanview(slot: &mut Option<MirSpanview>, v: Option<&str>) -> bool {
|
||||||
if v.is_some() {
|
if v.is_some() {
|
||||||
let mut bool_arg = None;
|
let mut bool_arg = None;
|
||||||
if parse_opt_bool(&mut bool_arg, v) {
|
if parse_opt_bool(&mut bool_arg, v) {
|
||||||
*slot = if bool_arg.unwrap() {
|
*slot = if bool_arg.unwrap() { Some(MirSpanview::Statement) } else { None };
|
||||||
Some(MirSpanview::Statement)
|
return true;
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,16 +667,15 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_instrument_coverage(slot: &mut Option<InstrumentCoverage>, v: Option<&str>) -> bool {
|
crate fn parse_instrument_coverage(
|
||||||
|
slot: &mut Option<InstrumentCoverage>,
|
||||||
|
v: Option<&str>,
|
||||||
|
) -> bool {
|
||||||
if v.is_some() {
|
if v.is_some() {
|
||||||
let mut bool_arg = None;
|
let mut bool_arg = None;
|
||||||
if parse_opt_bool(&mut bool_arg, v) {
|
if parse_opt_bool(&mut bool_arg, v) {
|
||||||
*slot = if bool_arg.unwrap() {
|
*slot = if bool_arg.unwrap() { Some(InstrumentCoverage::All) } else { None };
|
||||||
Some(InstrumentCoverage::All)
|
return true;
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -681,23 +701,25 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_treat_err_as_bug(slot: &mut Option<NonZeroUsize>, v: Option<&str>) -> bool {
|
crate fn parse_treat_err_as_bug(slot: &mut Option<NonZeroUsize>, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some(s) => { *slot = s.parse().ok(); slot.is_some() }
|
Some(s) => {
|
||||||
None => { *slot = NonZeroUsize::new(1); true }
|
*slot = s.parse().ok();
|
||||||
|
slot.is_some()
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
*slot = NonZeroUsize::new(1);
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
|
crate fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
|
||||||
if v.is_some() {
|
if v.is_some() {
|
||||||
let mut bool_arg = None;
|
let mut bool_arg = None;
|
||||||
if parse_opt_bool(&mut bool_arg, v) {
|
if parse_opt_bool(&mut bool_arg, v) {
|
||||||
*slot = if bool_arg.unwrap() {
|
*slot = if bool_arg.unwrap() { LtoCli::Yes } else { LtoCli::No };
|
||||||
LtoCli::Yes
|
return true;
|
||||||
} else {
|
|
||||||
LtoCli::No
|
|
||||||
};
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +732,7 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_linker_plugin_lto(slot: &mut LinkerPluginLto, v: Option<&str>) -> bool {
|
crate fn parse_linker_plugin_lto(slot: &mut LinkerPluginLto, v: Option<&str>) -> bool {
|
||||||
if v.is_some() {
|
if v.is_some() {
|
||||||
let mut bool_arg = None;
|
let mut bool_arg = None;
|
||||||
if parse_opt_bool(&mut bool_arg, v) {
|
if parse_opt_bool(&mut bool_arg, v) {
|
||||||
|
@ -719,7 +741,7 @@ macro_rules! options {
|
||||||
} else {
|
} else {
|
||||||
LinkerPluginLto::Disabled
|
LinkerPluginLto::Disabled
|
||||||
};
|
};
|
||||||
return true
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,7 +752,7 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_switch_with_opt_path(slot: &mut SwitchWithOptPath, v: Option<&str>) -> bool {
|
crate fn parse_switch_with_opt_path(slot: &mut SwitchWithOptPath, v: Option<&str>) -> bool {
|
||||||
*slot = match v {
|
*slot = match v {
|
||||||
None => SwitchWithOptPath::Enabled(None),
|
None => SwitchWithOptPath::Enabled(None),
|
||||||
Some(path) => SwitchWithOptPath::Enabled(Some(PathBuf::from(path))),
|
Some(path) => SwitchWithOptPath::Enabled(Some(PathBuf::from(path))),
|
||||||
|
@ -738,7 +760,7 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_merge_functions(slot: &mut Option<MergeFunctions>, v: Option<&str>) -> bool {
|
crate fn parse_merge_functions(slot: &mut Option<MergeFunctions>, v: Option<&str>) -> bool {
|
||||||
match v.and_then(|s| MergeFunctions::from_str(s).ok()) {
|
match v.and_then(|s| MergeFunctions::from_str(s).ok()) {
|
||||||
Some(mergefunc) => *slot = Some(mergefunc),
|
Some(mergefunc) => *slot = Some(mergefunc),
|
||||||
_ => return false,
|
_ => return false,
|
||||||
|
@ -746,7 +768,7 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_relocation_model(slot: &mut Option<RelocModel>, v: Option<&str>) -> bool {
|
crate fn parse_relocation_model(slot: &mut Option<RelocModel>, v: Option<&str>) -> bool {
|
||||||
match v.and_then(|s| RelocModel::from_str(s).ok()) {
|
match v.and_then(|s| RelocModel::from_str(s).ok()) {
|
||||||
Some(relocation_model) => *slot = Some(relocation_model),
|
Some(relocation_model) => *slot = Some(relocation_model),
|
||||||
None if v == Some("default") => *slot = None,
|
None if v == Some("default") => *slot = None,
|
||||||
|
@ -755,7 +777,7 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_code_model(slot: &mut Option<CodeModel>, v: Option<&str>) -> bool {
|
crate fn parse_code_model(slot: &mut Option<CodeModel>, v: Option<&str>) -> bool {
|
||||||
match v.and_then(|s| CodeModel::from_str(s).ok()) {
|
match v.and_then(|s| CodeModel::from_str(s).ok()) {
|
||||||
Some(code_model) => *slot = Some(code_model),
|
Some(code_model) => *slot = Some(code_model),
|
||||||
_ => return false,
|
_ => return false,
|
||||||
|
@ -763,7 +785,7 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_tls_model(slot: &mut Option<TlsModel>, v: Option<&str>) -> bool {
|
crate fn parse_tls_model(slot: &mut Option<TlsModel>, v: Option<&str>) -> bool {
|
||||||
match v.and_then(|s| TlsModel::from_str(s).ok()) {
|
match v.and_then(|s| TlsModel::from_str(s).ok()) {
|
||||||
Some(tls_model) => *slot = Some(tls_model),
|
Some(tls_model) => *slot = Some(tls_model),
|
||||||
_ => return false,
|
_ => return false,
|
||||||
|
@ -771,7 +793,7 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_symbol_mangling_version(
|
crate fn parse_symbol_mangling_version(
|
||||||
slot: &mut Option<SymbolManglingVersion>,
|
slot: &mut Option<SymbolManglingVersion>,
|
||||||
v: Option<&str>,
|
v: Option<&str>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
@ -783,7 +805,10 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_src_file_hash(slot: &mut Option<SourceFileHashAlgorithm>, v: Option<&str>) -> bool {
|
crate fn parse_src_file_hash(
|
||||||
|
slot: &mut Option<SourceFileHashAlgorithm>,
|
||||||
|
v: Option<&str>,
|
||||||
|
) -> bool {
|
||||||
match v.and_then(|s| SourceFileHashAlgorithm::from_str(s).ok()) {
|
match v.and_then(|s| SourceFileHashAlgorithm::from_str(s).ok()) {
|
||||||
Some(hash_kind) => *slot = Some(hash_kind),
|
Some(hash_kind) => *slot = Some(hash_kind),
|
||||||
_ => return false,
|
_ => return false,
|
||||||
|
@ -791,7 +816,7 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
|
crate fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
if !slot.is_empty() {
|
if !slot.is_empty() {
|
||||||
|
@ -804,7 +829,7 @@ macro_rules! options {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_wasi_exec_model(slot: &mut Option<WasiExecModel>, v: Option<&str>) -> bool {
|
crate fn parse_wasi_exec_model(slot: &mut Option<WasiExecModel>, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some("command") => *slot = Some(WasiExecModel::Command),
|
Some("command") => *slot = Some(WasiExecModel::Command),
|
||||||
Some("reactor") => *slot = Some(WasiExecModel::Reactor),
|
Some("reactor") => *slot = Some(WasiExecModel::Reactor),
|
||||||
|
@ -813,7 +838,7 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_split_debuginfo(slot: &mut Option<SplitDebuginfo>, v: Option<&str>) -> bool {
|
crate fn parse_split_debuginfo(slot: &mut Option<SplitDebuginfo>, v: Option<&str>) -> bool {
|
||||||
match v.and_then(|s| SplitDebuginfo::from_str(s).ok()) {
|
match v.and_then(|s| SplitDebuginfo::from_str(s).ok()) {
|
||||||
Some(e) => *slot = Some(e),
|
Some(e) => *slot = Some(e),
|
||||||
_ => return false,
|
_ => return false,
|
||||||
|
@ -821,11 +846,10 @@ macro_rules! options {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) }
|
|
||||||
|
|
||||||
options! {CodegenOptions, CodegenSetter, basic_codegen_options,
|
options! {CodegenOptions, CodegenSetter, basic_codegen_options,
|
||||||
build_codegen_options, "C", "codegen",
|
build_codegen_options, "C", "codegen",
|
||||||
CG_OPTIONS, cg_type_desc, cgsetters,
|
CG_OPTIONS,
|
||||||
|
|
||||||
// This list is in alphabetical order.
|
// This list is in alphabetical order.
|
||||||
//
|
//
|
||||||
|
@ -935,7 +959,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
|
||||||
|
|
||||||
options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
||||||
build_debugging_options, "Z", "debugging",
|
build_debugging_options, "Z", "debugging",
|
||||||
DB_OPTIONS, db_type_desc, dbsetters,
|
DB_OPTIONS,
|
||||||
|
|
||||||
// This list is in alphabetical order.
|
// This list is in alphabetical order.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue