diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-13 13:34:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-13 13:34:41 +0200 |
| commit | 5af528a03a0731651c303b9021c15fcb6404beba (patch) | |
| tree | affa4cb3016e3b20a66ff45056a4a4ca7e756fa8 /src/libsyntax | |
| parent | b143aa2b387920e4076e17d9c42c7bd4e2aebc36 (diff) | |
| parent | 477a68b720ffa7aad13a2f321af47b1851fe5ddb (diff) | |
| download | rust-5af528a03a0731651c303b9021c15fcb6404beba.tar.gz rust-5af528a03a0731651c303b9021c15fcb6404beba.zip | |
Rollup merge of #65358 - Centril:smsf, r=davidtwco
simplify maybe_stage_features Extracted from https://github.com/rust-lang/rust/pull/65324. r? @estebank
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/feature_gate/check.rs | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs index 9e40b1a26ac..6008f8f3005 100644 --- a/src/libsyntax/feature_gate/check.rs +++ b/src/libsyntax/feature_gate/check.rs @@ -855,25 +855,19 @@ impl UnstableFeatures { pub fn is_nightly_build(&self) -> bool { match *self { UnstableFeatures::Allow | UnstableFeatures::Cheat => true, - _ => false, + UnstableFeatures::Disallow => false, } } } fn maybe_stage_features(span_handler: &Handler, krate: &ast::Crate, unstable: UnstableFeatures) { - let allow_features = match unstable { - UnstableFeatures::Allow => true, - UnstableFeatures::Disallow => false, - UnstableFeatures::Cheat => true - }; - if !allow_features { - for attr in &krate.attrs { - if attr.check_name(sym::feature) { - let release_channel = option_env!("CFG_RELEASE_CHANNEL").unwrap_or("(unknown)"); - span_err!(span_handler, attr.span, E0554, - "`#![feature]` may not be used on the {} release channel", - release_channel); - } + if !unstable.is_nightly_build() { + for attr in krate.attrs.iter().filter(|attr| attr.check_name(sym::feature)) { + span_err!( + span_handler, attr.span, E0554, + "`#![feature]` may not be used on the {} release channel", + option_env!("CFG_RELEASE_CHANNEL").unwrap_or("(unknown)") + ); } } } |
