Skip to content

Commit

Permalink
deduplicate inline is_nightly_build implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
TimNN committed Sep 26, 2016
1 parent 3f287ef commit ad81f11
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
5 changes: 1 addition & 4 deletions src/librustc/session/config.rs
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions src/librustc_driver/lib.rs
Expand Up @@ -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() {
Expand Down
11 changes: 4 additions & 7 deletions src/librustdoc/html/markdown.rs
Expand Up @@ -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())
Expand Down

0 comments on commit ad81f11

Please sign in to comment.