Skip to content

Commit 477a68b

Browse files
committed
simplify maybe_stage_features
1 parent 1721c96 commit 477a68b

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/libsyntax/feature_gate/check.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -855,25 +855,19 @@ impl UnstableFeatures {
855855
pub fn is_nightly_build(&self) -> bool {
856856
match *self {
857857
UnstableFeatures::Allow | UnstableFeatures::Cheat => true,
858-
_ => false,
858+
UnstableFeatures::Disallow => false,
859859
}
860860
}
861861
}
862862

863863
fn maybe_stage_features(span_handler: &Handler, krate: &ast::Crate, unstable: UnstableFeatures) {
864-
let allow_features = match unstable {
865-
UnstableFeatures::Allow => true,
866-
UnstableFeatures::Disallow => false,
867-
UnstableFeatures::Cheat => true
868-
};
869-
if !allow_features {
870-
for attr in &krate.attrs {
871-
if attr.check_name(sym::feature) {
872-
let release_channel = option_env!("CFG_RELEASE_CHANNEL").unwrap_or("(unknown)");
873-
span_err!(span_handler, attr.span, E0554,
874-
"`#![feature]` may not be used on the {} release channel",
875-
release_channel);
876-
}
864+
if !unstable.is_nightly_build() {
865+
for attr in krate.attrs.iter().filter(|attr| attr.check_name(sym::feature)) {
866+
span_err!(
867+
span_handler, attr.span, E0554,
868+
"`#![feature]` may not be used on the {} release channel",
869+
option_env!("CFG_RELEASE_CHANNEL").unwrap_or("(unknown)")
870+
);
877871
}
878872
}
879873
}

0 commit comments

Comments
 (0)