1
Fork 0

Convenience funcs for some_option.unwrap_or(...)

This ensures consistent handling of default values for options that are
None if not specified on the command line.
This commit is contained in:
Rich Kadel 2020-12-14 13:12:15 -08:00
parent 4f550f1f93
commit 36c639a2ce
15 changed files with 29 additions and 55 deletions

View file

@ -174,8 +174,6 @@ pub enum MirSpanview {
Block,
}
pub const MIR_OPT_LEVEL_DEFAULT: usize = 1;
#[derive(Clone, PartialEq, Hash)]
pub enum LinkerPluginLto {
LinkerPlugin(PathBuf),
@ -214,12 +212,6 @@ pub enum SymbolManglingVersion {
V0,
}
impl SymbolManglingVersion {
pub fn default() -> Self {
SymbolManglingVersion::Legacy
}
}
impl_stable_hash_via_hash!(SymbolManglingVersion);
#[derive(Clone, Copy, Debug, PartialEq, Hash)]
@ -700,6 +692,10 @@ impl DebuggingOptions {
deduplicate_diagnostics: self.deduplicate_diagnostics,
}
}
pub fn get_symbol_mangling_version(&self) -> SymbolManglingVersion {
self.symbol_mangling_version.unwrap_or(SymbolManglingVersion::Legacy)
}
}
// The type of entry function, so users can have their own entry functions
@ -1779,18 +1775,15 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
Some(SymbolManglingVersion::V0) => {}
}
match debugging_opts.mir_opt_level {
Some(level) if level > 1 => {
early_warn(
error_format,
&format!(
"`-Z mir-opt-level={}` (any level > 1) enables function inlining, which \
limits the effectiveness of `-Z instrument-coverage`.",
level,
),
);
}
_ => {}
if debugging_opts.mir_opt_level > 1 {
early_warn(
error_format,
&format!(
"`-Z mir-opt-level={}` (any level > 1) enables function inlining, which \
limits the effectiveness of `-Z instrument-coverage`.",
debugging_opts.mir_opt_level,
),
);
}
}