diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/session/config.rs | 6 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/lib.rs | 1 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/llvm_util.rs | 2 | ||||
| -rw-r--r-- | src/librustc_driver/lib.rs | 6 | ||||
| -rw-r--r-- | src/librustc_feature/lib.rs | 34 | ||||
| -rw-r--r-- | src/librustdoc/core.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/externalfiles.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/html/render.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/markdown.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/passes/collect_intra_doc_links.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/test.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate/check.rs | 40 | ||||
| -rw-r--r-- | src/libsyntax/lib.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/sess.rs | 4 | 
14 files changed, 52 insertions, 55 deletions
| diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 6733250e1e8..fbfae721bbe 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -7,6 +7,7 @@ use crate::session::{early_error, early_warn, Session}; use crate::session::search_paths::SearchPath; use rustc_data_structures::fx::FxHashSet; +use rustc_feature::UnstableFeatures; use rustc_target::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, RelroLevel}; use rustc_target::spec::{Target, TargetTriple}; @@ -16,7 +17,6 @@ use syntax::ast; use syntax::source_map::{FileName, FilePathMapping}; use syntax::edition::{Edition, EDITION_NAME_LIST, DEFAULT_EDITION}; use syntax::symbol::{sym, Symbol}; -use syntax::feature_gate::UnstableFeatures; use errors::emitter::HumanReadableErrorType; use errors::{ColorConfig, FatalError, Handler}; @@ -2701,7 +2701,7 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy pub mod nightly_options { use getopts; - use syntax::feature_gate::UnstableFeatures; + use rustc_feature::UnstableFeatures; use super::{ErrorOutputType, OptionStability, RustcOptGroup}; use crate::session::early_error; @@ -2850,9 +2850,9 @@ mod dep_tracking { use super::{CrateType, DebugInfo, ErrorOutputType, OptLevel, OutputTypes, Passes, Sanitizer, LtoCli, LinkerPluginLto, SwitchWithOptPath, SymbolManglingVersion}; + use rustc_feature::UnstableFeatures; use rustc_target::spec::{MergeFunctions, PanicStrategy, RelroLevel, TargetTriple}; use syntax::edition::Edition; - use syntax::feature_gate::UnstableFeatures; pub trait DepTrackingHash { fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType); diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index e7562c399b2..acc221f0657 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -30,6 +30,7 @@ extern crate libc; #[macro_use] extern crate rustc; extern crate rustc_target; #[macro_use] extern crate rustc_data_structures; +extern crate rustc_feature; extern crate rustc_index; extern crate rustc_incremental; extern crate rustc_codegen_utils; diff --git a/src/librustc_codegen_llvm/llvm_util.rs b/src/librustc_codegen_llvm/llvm_util.rs index 290ca409261..7bff9e69dd5 100644 --- a/src/librustc_codegen_llvm/llvm_util.rs +++ b/src/librustc_codegen_llvm/llvm_util.rs @@ -6,7 +6,7 @@ use rustc::session::config::PrintRequest; use rustc_target::spec::{MergeFunctions, PanicStrategy}; use libc::c_int; use std::ffi::CString; -use syntax::feature_gate::UnstableFeatures; +use rustc_feature::UnstableFeatures; use syntax::symbol::sym; use std::str; diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 89ef402bdb5..073e117f6db 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -44,8 +44,7 @@ use errors::{PResult, registry::Registry}; use rustc_interface::interface; use rustc_interface::util::get_codegen_sysroot; use rustc_data_structures::sync::SeqCst; -use rustc_feature::find_gated_cfg; - +use rustc_feature::{find_gated_cfg, UnstableFeatures}; use rustc_serialize::json::ToJson; use std::borrow::Cow; @@ -62,8 +61,7 @@ use std::str; use std::time::Instant; use syntax::ast; -use syntax::source_map::FileLoader; -use syntax::feature_gate::UnstableFeatures; +use syntax_pos::source_map::FileLoader; use syntax_pos::symbol::sym; use syntax_pos::FileName; diff --git a/src/librustc_feature/lib.rs b/src/librustc_feature/lib.rs index bda1449d85c..e8ed1f377e5 100644 --- a/src/librustc_feature/lib.rs +++ b/src/librustc_feature/lib.rs @@ -65,6 +65,40 @@ pub enum Stability { Deprecated(&'static str, Option<&'static str>), } +#[derive(Clone, Copy, Hash)] +pub enum UnstableFeatures { + /// Hard errors for unstable features are active, as on beta/stable channels. + Disallow, + /// Allow features to be 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 is always required for building Rust itself. + Cheat +} + +impl UnstableFeatures { + pub fn from_environment() -> UnstableFeatures { + // `true` if this is a feature-staged build, i.e., on the beta or stable channel. + let disable_unstable_features = option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some(); + // `true` if we should enable unstable features for bootstrapping. + let bootstrap = std::env::var("RUSTC_BOOTSTRAP").is_ok(); + match (disable_unstable_features, bootstrap) { + (_, true) => UnstableFeatures::Cheat, + (true, _) => UnstableFeatures::Disallow, + (false, _) => UnstableFeatures::Allow + } + } + + pub fn is_nightly_build(&self) -> bool { + match *self { + UnstableFeatures::Allow | UnstableFeatures::Cheat => true, + UnstableFeatures::Disallow => false, + } + } +} + pub use accepted::ACCEPTED_FEATURES; pub use active::{ACTIVE_FEATURES, Features, INCOMPLETE_FEATURES}; pub use removed::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES}; diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 612f3c69871..9e03896d980 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -12,12 +12,12 @@ use rustc::session::DiagnosticOutput; use rustc::util::nodemap::{FxHashMap, FxHashSet}; use rustc_interface::interface; use rustc_driver::abort_on_err; +use rustc_feature::UnstableFeatures; use rustc_resolve as resolve; use syntax::ast::CRATE_NODE_ID; use syntax::source_map; use syntax::attr; -use syntax::feature_gate::UnstableFeatures; use errors::json::JsonEmitter; use syntax::symbol::sym; use syntax_pos::DUMMY_SP; diff --git a/src/librustdoc/externalfiles.rs b/src/librustdoc/externalfiles.rs index 56f1191feed..7945850ef08 100644 --- a/src/librustdoc/externalfiles.rs +++ b/src/librustdoc/externalfiles.rs @@ -2,7 +2,7 @@ use std::fs; use std::path::Path; use std::str; use errors; -use crate::syntax::feature_gate::UnstableFeatures; +use rustc_feature::UnstableFeatures; use crate::syntax::edition::Edition; use crate::html::markdown::{IdMap, ErrorCodes, Markdown, Playground}; diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index ba94cb82c00..b5c1a77a387 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -45,7 +45,6 @@ use errors; use serialize::json::{ToJson, Json, as_json}; use syntax::ast; use syntax::edition::Edition; -use syntax::feature_gate::UnstableFeatures; use syntax::print::pprust; use syntax::source_map::FileName; use syntax::symbol::{Symbol, sym}; @@ -56,6 +55,7 @@ use rustc::middle::stability; use rustc::hir; use rustc::util::nodemap::{FxHashMap, FxHashSet}; use rustc_data_structures::flock; +use rustc_feature::UnstableFeatures; use crate::clean::{self, AttributesExt, Deprecation, GetDefId, SelfTy, Mutability}; use crate::config::RenderOptions; diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index 8431271e62d..7dc3df23a6d 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -6,7 +6,7 @@ use errors; use testing; use syntax::edition::Edition; use syntax::source_map::DUMMY_SP; -use syntax::feature_gate::UnstableFeatures; +use rustc_feature::UnstableFeatures; use crate::externalfiles::{LoadStringError, load_string}; use crate::config::{Options, RenderOptions}; diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index d8f2dbca835..3c021ae7465 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -5,10 +5,10 @@ use rustc::hir; use rustc::lint as lint; use rustc::ty; use rustc_resolve::ParentScope; +use rustc_feature::UnstableFeatures; use syntax; use syntax::ast::{self, Ident}; use syntax_expand::base::SyntaxExtensionKind; -use syntax::feature_gate::UnstableFeatures; use syntax::symbol::Symbol; use syntax_pos::DUMMY_SP; diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 22f209b8bad..cf5fb06fa56 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -1,4 +1,5 @@ use rustc_data_structures::sync::Lrc; +use rustc_feature::UnstableFeatures; use rustc_interface::interface; use rustc_target::spec::TargetTriple; use rustc::hir; @@ -9,7 +10,6 @@ use syntax::ast; use syntax::with_globals; use syntax::source_map::SourceMap; use syntax::edition::Edition; -use syntax::feature_gate::UnstableFeatures; use std::env; use std::io::{self, Write}; use std::panic; diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs index c53f5f41e32..141b324baa8 100644 --- a/src/libsyntax/feature_gate/check.rs +++ b/src/libsyntax/feature_gate/check.rs @@ -1,6 +1,6 @@ -use rustc_feature::{ACCEPTED_FEATURES, ACTIVE_FEATURES, Features, Feature, State as FeatureState}; -use rustc_feature::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES}; +use rustc_feature::{ACCEPTED_FEATURES, ACTIVE_FEATURES, REMOVED_FEATURES, STABLE_REMOVED_FEATURES}; use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP}; +use rustc_feature::{Features, Feature, State as FeatureState, UnstableFeatures}; use crate::ast::{self, AssocTyConstraint, AssocTyConstraintKind, NodeId}; use crate::ast::{GenericParam, GenericParamKind, PatKind, RangeEnd, VariantData}; @@ -18,8 +18,6 @@ use log::debug; use rustc_error_codes::*; - -use std::env; use std::num::NonZeroU32; macro_rules! gate_feature_fn { @@ -880,40 +878,6 @@ pub fn check_crate(krate: &ast::Crate, visit::walk_crate(&mut visitor, krate); } -#[derive(Clone, Copy, Hash)] -pub enum UnstableFeatures { - /// Hard errors for unstable features are active, as on beta/stable channels. - Disallow, - /// Allow features to be 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 is always required for building Rust itself. - Cheat -} - -impl UnstableFeatures { - pub fn from_environment() -> UnstableFeatures { - // `true` if this is a feature-staged build, i.e., on the beta or stable channel. - let disable_unstable_features = option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some(); - // `true` if we should enable unstable features for bootstrapping. - let bootstrap = env::var("RUSTC_BOOTSTRAP").is_ok(); - match (disable_unstable_features, bootstrap) { - (_, true) => UnstableFeatures::Cheat, - (true, _) => UnstableFeatures::Disallow, - (false, _) => UnstableFeatures::Allow - } - } - - pub fn is_nightly_build(&self) -> bool { - match *self { - UnstableFeatures::Allow | UnstableFeatures::Cheat => true, - UnstableFeatures::Disallow => false, - } - } -} - fn maybe_stage_features(span_handler: &Handler, krate: &ast::Crate, unstable: UnstableFeatures) { if !unstable.is_nightly_build() { for attr in krate.attrs.iter().filter(|attr| attr.check_name(sym::feature)) { diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index fda95374f64..c2d887c9267 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -96,7 +96,7 @@ pub mod feature_gate { mod check; pub use check::{ check_crate, check_attribute, get_features, feature_err, emit_feature_err, - GateIssue, UnstableFeatures, + GateIssue, }; } pub mod mut_visit; diff --git a/src/libsyntax/sess.rs b/src/libsyntax/sess.rs index 740e9dfe459..aa9217c1b69 100644 --- a/src/libsyntax/sess.rs +++ b/src/libsyntax/sess.rs @@ -3,15 +3,15 @@ use crate::ast::{CrateConfig, NodeId}; use crate::early_buffered_lints::{BufferedEarlyLint, BufferedEarlyLintId}; -use crate::source_map::{SourceMap, FilePathMapping}; -use crate::feature_gate::UnstableFeatures; use errors::{Applicability, emitter::SilentEmitter, Handler, ColorConfig, DiagnosticBuilder}; use rustc_data_structures::fx::{FxHashSet, FxHashMap}; use rustc_data_structures::sync::{Lrc, Lock, Once}; +use rustc_feature::UnstableFeatures; use syntax_pos::{Symbol, Span, MultiSpan}; use syntax_pos::edition::Edition; use syntax_pos::hygiene::ExpnId; +use syntax_pos::source_map::{SourceMap, FilePathMapping}; use std::path::PathBuf; use std::str; | 
