Skip to content

Commit b45f21d

Browse files
committed
move UnstableFeatures -> rustc_feature
1 parent db89679 commit b45f21d

File tree

14 files changed

+52
-55
lines changed

14 files changed

+52
-55
lines changed

src/librustc/session/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::session::{early_error, early_warn, Session};
77
use crate::session::search_paths::SearchPath;
88

99
use rustc_data_structures::fx::FxHashSet;
10+
use rustc_feature::UnstableFeatures;
1011

1112
use rustc_target::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, RelroLevel};
1213
use rustc_target::spec::{Target, TargetTriple};
@@ -16,7 +17,6 @@ use syntax::ast;
1617
use syntax::source_map::{FileName, FilePathMapping};
1718
use syntax::edition::{Edition, EDITION_NAME_LIST, DEFAULT_EDITION};
1819
use syntax::symbol::{sym, Symbol};
19-
use syntax::feature_gate::UnstableFeatures;
2020

2121
use errors::emitter::HumanReadableErrorType;
2222
use errors::{ColorConfig, FatalError, Handler};
@@ -2701,7 +2701,7 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
27012701

27022702
pub mod nightly_options {
27032703
use getopts;
2704-
use syntax::feature_gate::UnstableFeatures;
2704+
use rustc_feature::UnstableFeatures;
27052705
use super::{ErrorOutputType, OptionStability, RustcOptGroup};
27062706
use crate::session::early_error;
27072707

@@ -2850,9 +2850,9 @@ mod dep_tracking {
28502850
use super::{CrateType, DebugInfo, ErrorOutputType, OptLevel, OutputTypes,
28512851
Passes, Sanitizer, LtoCli, LinkerPluginLto, SwitchWithOptPath,
28522852
SymbolManglingVersion};
2853+
use rustc_feature::UnstableFeatures;
28532854
use rustc_target::spec::{MergeFunctions, PanicStrategy, RelroLevel, TargetTriple};
28542855
use syntax::edition::Edition;
2855-
use syntax::feature_gate::UnstableFeatures;
28562856

28572857
pub trait DepTrackingHash {
28582858
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType);

src/librustc_codegen_llvm/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extern crate libc;
3030
#[macro_use] extern crate rustc;
3131
extern crate rustc_target;
3232
#[macro_use] extern crate rustc_data_structures;
33+
extern crate rustc_feature;
3334
extern crate rustc_index;
3435
extern crate rustc_incremental;
3536
extern crate rustc_codegen_utils;

src/librustc_codegen_llvm/llvm_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc::session::config::PrintRequest;
66
use rustc_target::spec::{MergeFunctions, PanicStrategy};
77
use libc::c_int;
88
use std::ffi::CString;
9-
use syntax::feature_gate::UnstableFeatures;
9+
use rustc_feature::UnstableFeatures;
1010
use syntax::symbol::sym;
1111

1212
use std::str;

src/librustc_driver/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ use errors::{PResult, registry::Registry};
4444
use rustc_interface::interface;
4545
use rustc_interface::util::get_codegen_sysroot;
4646
use rustc_data_structures::sync::SeqCst;
47-
use rustc_feature::find_gated_cfg;
48-
47+
use rustc_feature::{find_gated_cfg, UnstableFeatures};
4948
use rustc_serialize::json::ToJson;
5049

5150
use std::borrow::Cow;
@@ -62,8 +61,7 @@ use std::str;
6261
use std::time::Instant;
6362

6463
use syntax::ast;
65-
use syntax::source_map::FileLoader;
66-
use syntax::feature_gate::UnstableFeatures;
64+
use syntax_pos::source_map::FileLoader;
6765
use syntax_pos::symbol::sym;
6866
use syntax_pos::FileName;
6967

src/librustc_feature/lib.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,40 @@ pub enum Stability {
6565
Deprecated(&'static str, Option<&'static str>),
6666
}
6767

68+
#[derive(Clone, Copy, Hash)]
69+
pub enum UnstableFeatures {
70+
/// Hard errors for unstable features are active, as on beta/stable channels.
71+
Disallow,
72+
/// Allow features to be activated, as on nightly.
73+
Allow,
74+
/// Errors are bypassed for bootstrapping. This is required any time
75+
/// during the build that feature-related lints are set to warn or above
76+
/// because the build turns on warnings-as-errors and uses lots of unstable
77+
/// features. As a result, this is always required for building Rust itself.
78+
Cheat
79+
}
80+
81+
impl UnstableFeatures {
82+
pub fn from_environment() -> UnstableFeatures {
83+
// `true` if this is a feature-staged build, i.e., on the beta or stable channel.
84+
let disable_unstable_features = option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some();
85+
// `true` if we should enable unstable features for bootstrapping.
86+
let bootstrap = std::env::var("RUSTC_BOOTSTRAP").is_ok();
87+
match (disable_unstable_features, bootstrap) {
88+
(_, true) => UnstableFeatures::Cheat,
89+
(true, _) => UnstableFeatures::Disallow,
90+
(false, _) => UnstableFeatures::Allow
91+
}
92+
}
93+
94+
pub fn is_nightly_build(&self) -> bool {
95+
match *self {
96+
UnstableFeatures::Allow | UnstableFeatures::Cheat => true,
97+
UnstableFeatures::Disallow => false,
98+
}
99+
}
100+
}
101+
68102
pub use accepted::ACCEPTED_FEATURES;
69103
pub use active::{ACTIVE_FEATURES, Features, INCOMPLETE_FEATURES};
70104
pub use removed::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES};

src/librustdoc/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ use rustc::session::DiagnosticOutput;
1212
use rustc::util::nodemap::{FxHashMap, FxHashSet};
1313
use rustc_interface::interface;
1414
use rustc_driver::abort_on_err;
15+
use rustc_feature::UnstableFeatures;
1516
use rustc_resolve as resolve;
1617

1718
use syntax::ast::CRATE_NODE_ID;
1819
use syntax::source_map;
1920
use syntax::attr;
20-
use syntax::feature_gate::UnstableFeatures;
2121
use errors::json::JsonEmitter;
2222
use syntax::symbol::sym;
2323
use syntax_pos::DUMMY_SP;

src/librustdoc/externalfiles.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::fs;
22
use std::path::Path;
33
use std::str;
44
use errors;
5-
use crate::syntax::feature_gate::UnstableFeatures;
5+
use rustc_feature::UnstableFeatures;
66
use crate::syntax::edition::Edition;
77
use crate::html::markdown::{IdMap, ErrorCodes, Markdown, Playground};
88

src/librustdoc/html/render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ use errors;
4545
use serialize::json::{ToJson, Json, as_json};
4646
use syntax::ast;
4747
use syntax::edition::Edition;
48-
use syntax::feature_gate::UnstableFeatures;
4948
use syntax::print::pprust;
5049
use syntax::source_map::FileName;
5150
use syntax::symbol::{Symbol, sym};
@@ -56,6 +55,7 @@ use rustc::middle::stability;
5655
use rustc::hir;
5756
use rustc::util::nodemap::{FxHashMap, FxHashSet};
5857
use rustc_data_structures::flock;
58+
use rustc_feature::UnstableFeatures;
5959

6060
use crate::clean::{self, AttributesExt, Deprecation, GetDefId, SelfTy, Mutability};
6161
use crate::config::RenderOptions;

src/librustdoc/markdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use errors;
66
use testing;
77
use syntax::edition::Edition;
88
use syntax::source_map::DUMMY_SP;
9-
use syntax::feature_gate::UnstableFeatures;
9+
use rustc_feature::UnstableFeatures;
1010

1111
use crate::externalfiles::{LoadStringError, load_string};
1212
use crate::config::{Options, RenderOptions};

src/librustdoc/passes/collect_intra_doc_links.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ use rustc::hir;
55
use rustc::lint as lint;
66
use rustc::ty;
77
use rustc_resolve::ParentScope;
8+
use rustc_feature::UnstableFeatures;
89
use syntax;
910
use syntax::ast::{self, Ident};
1011
use syntax_expand::base::SyntaxExtensionKind;
11-
use syntax::feature_gate::UnstableFeatures;
1212
use syntax::symbol::Symbol;
1313
use syntax_pos::DUMMY_SP;
1414

src/librustdoc/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use rustc_data_structures::sync::Lrc;
2+
use rustc_feature::UnstableFeatures;
23
use rustc_interface::interface;
34
use rustc_target::spec::TargetTriple;
45
use rustc::hir;
@@ -9,7 +10,6 @@ use syntax::ast;
910
use syntax::with_globals;
1011
use syntax::source_map::SourceMap;
1112
use syntax::edition::Edition;
12-
use syntax::feature_gate::UnstableFeatures;
1313
use std::env;
1414
use std::io::{self, Write};
1515
use std::panic;

src/libsyntax/feature_gate/check.rs

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use rustc_feature::{ACCEPTED_FEATURES, ACTIVE_FEATURES, Features, Feature, State as FeatureState};
2-
use rustc_feature::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES};
1+
use rustc_feature::{ACCEPTED_FEATURES, ACTIVE_FEATURES, REMOVED_FEATURES, STABLE_REMOVED_FEATURES};
32
use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP};
3+
use rustc_feature::{Features, Feature, State as FeatureState, UnstableFeatures};
44

55
use crate::ast::{self, AssocTyConstraint, AssocTyConstraintKind, NodeId};
66
use crate::ast::{GenericParam, GenericParamKind, PatKind, RangeEnd, VariantData};
@@ -18,8 +18,6 @@ use log::debug;
1818

1919
use rustc_error_codes::*;
2020

21-
22-
use std::env;
2321
use std::num::NonZeroU32;
2422

2523
macro_rules! gate_feature_fn {
@@ -880,40 +878,6 @@ pub fn check_crate(krate: &ast::Crate,
880878
visit::walk_crate(&mut visitor, krate);
881879
}
882880

883-
#[derive(Clone, Copy, Hash)]
884-
pub enum UnstableFeatures {
885-
/// Hard errors for unstable features are active, as on beta/stable channels.
886-
Disallow,
887-
/// Allow features to be activated, as on nightly.
888-
Allow,
889-
/// Errors are bypassed for bootstrapping. This is required any time
890-
/// during the build that feature-related lints are set to warn or above
891-
/// because the build turns on warnings-as-errors and uses lots of unstable
892-
/// features. As a result, this is always required for building Rust itself.
893-
Cheat
894-
}
895-
896-
impl UnstableFeatures {
897-
pub fn from_environment() -> UnstableFeatures {
898-
// `true` if this is a feature-staged build, i.e., on the beta or stable channel.
899-
let disable_unstable_features = option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some();
900-
// `true` if we should enable unstable features for bootstrapping.
901-
let bootstrap = env::var("RUSTC_BOOTSTRAP").is_ok();
902-
match (disable_unstable_features, bootstrap) {
903-
(_, true) => UnstableFeatures::Cheat,
904-
(true, _) => UnstableFeatures::Disallow,
905-
(false, _) => UnstableFeatures::Allow
906-
}
907-
}
908-
909-
pub fn is_nightly_build(&self) -> bool {
910-
match *self {
911-
UnstableFeatures::Allow | UnstableFeatures::Cheat => true,
912-
UnstableFeatures::Disallow => false,
913-
}
914-
}
915-
}
916-
917881
fn maybe_stage_features(span_handler: &Handler, krate: &ast::Crate, unstable: UnstableFeatures) {
918882
if !unstable.is_nightly_build() {
919883
for attr in krate.attrs.iter().filter(|attr| attr.check_name(sym::feature)) {

src/libsyntax/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub mod feature_gate {
9696
mod check;
9797
pub use check::{
9898
check_crate, check_attribute, get_features, feature_err, emit_feature_err,
99-
GateIssue, UnstableFeatures,
99+
GateIssue,
100100
};
101101
}
102102
pub mod mut_visit;

src/libsyntax/sess.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
44
use crate::ast::{CrateConfig, NodeId};
55
use crate::early_buffered_lints::{BufferedEarlyLint, BufferedEarlyLintId};
6-
use crate::source_map::{SourceMap, FilePathMapping};
7-
use crate::feature_gate::UnstableFeatures;
86

97
use errors::{Applicability, emitter::SilentEmitter, Handler, ColorConfig, DiagnosticBuilder};
108
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
119
use rustc_data_structures::sync::{Lrc, Lock, Once};
10+
use rustc_feature::UnstableFeatures;
1211
use syntax_pos::{Symbol, Span, MultiSpan};
1312
use syntax_pos::edition::Edition;
1413
use syntax_pos::hygiene::ExpnId;
14+
use syntax_pos::source_map::{SourceMap, FilePathMapping};
1515

1616
use std::path::PathBuf;
1717
use std::str;

0 commit comments

Comments
 (0)