@@ -33,10 +33,11 @@ use syntax::diagnostic::{ColorConfig, Auto, Always, Never, SpanHandler};
33
33
use syntax:: parse;
34
34
use syntax:: parse:: token:: InternedString ;
35
35
36
+ use getopts;
36
37
use std:: collections:: HashMap ;
37
38
use std:: collections:: hash_map:: Entry :: { Occupied , Vacant } ;
38
- use getopts;
39
39
use std:: fmt;
40
+ use std:: os;
40
41
41
42
use llvm;
42
43
@@ -821,7 +822,6 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {
821
822
}
822
823
823
824
pub fn build_session_options ( matches : & getopts:: Matches ) -> Options {
824
-
825
825
let unparsed_crate_types = matches. opt_strs ( "crate-type" ) ;
826
826
let crate_types = parse_crate_types_from_list ( unparsed_crate_types)
827
827
. unwrap_or_else ( |e| early_error ( & e[ ] ) ) ;
@@ -1041,7 +1041,22 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1041
1041
crate_name : crate_name,
1042
1042
alt_std_name : None ,
1043
1043
libs : libs,
1044
- unstable_features : UnstableFeatures :: Disallow
1044
+ unstable_features : get_unstable_features_setting ( ) ,
1045
+ }
1046
+ }
1047
+
1048
+ pub fn get_unstable_features_setting ( ) -> UnstableFeatures {
1049
+ // Whether this is a feature-staged build, i.e. on the beta or stable channel
1050
+ let disable_unstable_features = option_env ! ( "CFG_DISABLE_UNSTABLE_FEATURES" ) . is_some ( ) ;
1051
+ // The secret key needed to get through the rustc build itself by
1052
+ // subverting the unstable features lints
1053
+ let bootstrap_secret_key = option_env ! ( "CFG_BOOTSTRAP_KEY" ) ;
1054
+ // The matching key to the above, only known by the build system
1055
+ let bootstrap_provided_key = env:: var_string ( "RUSTC_BOOTSTRAP_KEY" ) . ok ( ) ;
1056
+ match ( disable_unstable_features, bootstrap_secret_key, bootstrap_provided_key) {
1057
+ ( _, Some ( ref s) , Some ( ref p) ) if s == p => UnstableFeatures :: Cheat ,
1058
+ ( true , _, _) => UnstableFeatures :: Disallow ,
1059
+ ( false , _, _) => UnstableFeatures :: Default
1045
1060
}
1046
1061
}
1047
1062
0 commit comments