Skip to content

Commit ad81f11

Browse files
committed
deduplicate inline is_nightly_build implementations
1 parent 3f287ef commit ad81f11

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

src/librustc/session/config.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,10 +1572,7 @@ pub mod nightly_options {
15721572

15731573
pub fn check_nightly_options(matches: &getopts::Matches, flags: &[RustcOptGroup]) {
15741574
let has_z_unstable_option = matches.opt_strs("Z").iter().any(|x| *x == "unstable-options");
1575-
let really_allows_unstable_options = match UnstableFeatures::from_environment() {
1576-
UnstableFeatures::Disallow => false,
1577-
_ => true,
1578-
};
1575+
let really_allows_unstable_options = UnstableFeatures::from_environment().is_nightly_build();
15791576

15801577
for opt in flags.iter() {
15811578
if opt.stability == OptionStability::Stable {

src/librustc_driver/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,7 @@ impl RustcDefaultCalls {
649649
}
650650
}
651651
PrintRequest::Cfg => {
652-
let allow_unstable_cfg = match UnstableFeatures::from_environment() {
653-
UnstableFeatures::Disallow => false,
654-
_ => true,
655-
};
652+
let allow_unstable_cfg = UnstableFeatures::from_environment().is_nightly_build();
656653

657654
for cfg in cfg {
658655
if !allow_unstable_cfg && GatedCfg::gate(&*cfg).is_some() {

src/librustdoc/html/markdown.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,10 @@ impl LangString {
477477
let mut data = LangString::all_false();
478478
let mut allow_compile_fail = false;
479479
let mut allow_error_code_check = false;
480-
match UnstableFeatures::from_environment() {
481-
UnstableFeatures::Allow | UnstableFeatures::Cheat => {
482-
allow_compile_fail = true;
483-
allow_error_code_check = true;
484-
}
485-
_ => {},
486-
};
480+
if UnstableFeatures::from_environment().is_nightly_build() {
481+
allow_compile_fail = true;
482+
allow_error_code_check = true;
483+
}
487484

488485
let tokens = string.split(|c: char|
489486
!(c == '_' || c == '-' || c.is_alphanumeric())

0 commit comments

Comments
 (0)