deduplicate inline is_nightly_build implementations

This commit is contained in:
Tim Neumann 2016-09-24 19:26:18 +02:00
parent 3f287efc82
commit ad81f11b01
3 changed files with 6 additions and 15 deletions

View File

@ -1572,10 +1572,7 @@ pub mod nightly_options {
pub fn check_nightly_options(matches: &getopts::Matches, flags: &[RustcOptGroup]) {
let has_z_unstable_option = matches.opt_strs("Z").iter().any(|x| *x == "unstable-options");
let really_allows_unstable_options = match UnstableFeatures::from_environment() {
UnstableFeatures::Disallow => false,
_ => true,
};
let really_allows_unstable_options = UnstableFeatures::from_environment().is_nightly_build();
for opt in flags.iter() {
if opt.stability == OptionStability::Stable {

View File

@ -649,10 +649,7 @@ impl RustcDefaultCalls {
}
}
PrintRequest::Cfg => {
let allow_unstable_cfg = match UnstableFeatures::from_environment() {
UnstableFeatures::Disallow => false,
_ => true,
};
let allow_unstable_cfg = UnstableFeatures::from_environment().is_nightly_build();
for cfg in cfg {
if !allow_unstable_cfg && GatedCfg::gate(&*cfg).is_some() {

View File

@ -477,13 +477,10 @@ impl LangString {
let mut data = LangString::all_false();
let mut allow_compile_fail = false;
let mut allow_error_code_check = false;
match UnstableFeatures::from_environment() {
UnstableFeatures::Allow | UnstableFeatures::Cheat => {
allow_compile_fail = true;
allow_error_code_check = true;
}
_ => {},
};
if UnstableFeatures::from_environment().is_nightly_build() {
allow_compile_fail = true;
allow_error_code_check = true;
}
let tokens = string.split(|c: char|
!(c == '_' || c == '-' || c.is_alphanumeric())