diff options
| author | bors <bors@rust-lang.org> | 2015-06-20 14:24:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-06-20 14:24:19 +0000 |
| commit | 74a7e8b03eb60b240dd4f5d9c47e55cc61c908f3 (patch) | |
| tree | e6b6b6f61aa92b7a7f3aef37ce3e8e15f7e42265 /src/libsyntax | |
| parent | 3e4d1b4dec431601553a5e13a52f61f9493d10ee (diff) | |
| parent | f14a0e2de484c2a61c80128a442827059c05783f (diff) | |
| download | rust-74a7e8b03eb60b240dd4f5d9c47e55cc61c908f3.tar.gz rust-74a7e8b03eb60b240dd4f5d9c47e55cc61c908f3.zip | |
Auto merge of #26417 - brson:feature-err, r=steveklabnik
It now says '#[feature] may not be used on the stable release channel'. I had to convert this error from a lint to a normal compiler error. I left the lint previously-used for this in place since removing it is a breaking change. It will just go unused until the end of time. Fixes #24125
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index ea135c7a642..3d0cf9236c2 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -430,18 +430,6 @@ pub fn emit_feature_err(diag: &SpanHandler, feature: &str, span: Span, explain: feature)); } -pub fn emit_feature_warn(diag: &SpanHandler, feature: &str, span: Span, explain: &str) { - diag.span_warn(span, explain); - - // #23973: do not suggest `#![feature(...)]` if we are in beta/stable - if option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some() { return; } - if diag.handler.can_emit_warnings { - diag.fileline_help(span, &format!("add #![feature({})] to the \ - crate attributes to silence this warning", - feature)); - } -} - pub const EXPLAIN_ASM: &'static str = "inline assembly is not stable enough for use and is subject to change"; @@ -811,9 +799,46 @@ pub fn check_crate_macros(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast: } pub fn check_crate(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate, - plugin_attributes: &[(String, AttributeType)]) -> Features + plugin_attributes: &[(String, AttributeType)], + unstable: UnstableFeatures) -> Features { + maybe_stage_features(span_handler, krate, unstable); + check_crate_inner(cm, span_handler, krate, plugin_attributes, |ctx, krate| visit::walk_crate(&mut PostExpansionVisitor { context: ctx }, krate)) } + +#[derive(Clone, Copy)] +pub enum UnstableFeatures { + /// Hard errors for unstable features are active, as on + /// beta/stable channels. + Disallow, + /// Allow features to me activated, as on nightly. + Allow, + /// Errors are bypassed for bootstrapping. This is required any time + /// during the build that feature-related lints are set to warn or above + /// because the build turns on warnings-as-errors and uses lots of unstable + /// features. As a result, this this is always required for building Rust + /// itself. + Cheat +} + +fn maybe_stage_features(span_handler: &SpanHandler, 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("feature") { + let release_channel = option_env!("CFG_RELEASE_CHANNEL").unwrap_or("(unknown)"); + let ref msg = format!("#[feature] may not be used on the {} release channel", + release_channel); + span_handler.span_err(attr.span, msg); + } + } + } +} |
