@@ -37,7 +37,6 @@ use std::collections::btree_map::Iter as BTreeMapIter;
37
37
use std:: collections:: btree_map:: Keys as BTreeMapKeysIter ;
38
38
use std:: collections:: btree_map:: Values as BTreeMapValuesIter ;
39
39
40
- use std:: env;
41
40
use std:: fmt;
42
41
use std:: hash:: { Hasher , SipHasher } ;
43
42
use std:: iter:: FromIterator ;
@@ -1525,27 +1524,12 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
1525
1524
crate_name : crate_name,
1526
1525
alt_std_name : None ,
1527
1526
libs : libs,
1528
- unstable_features : get_unstable_features_setting ( ) ,
1527
+ unstable_features : UnstableFeatures :: from_environment ( ) ,
1529
1528
debug_assertions : debug_assertions,
1530
1529
} ,
1531
1530
cfg)
1532
1531
}
1533
1532
1534
- pub fn get_unstable_features_setting ( ) -> UnstableFeatures {
1535
- // Whether this is a feature-staged build, i.e. on the beta or stable channel
1536
- let disable_unstable_features = option_env ! ( "CFG_DISABLE_UNSTABLE_FEATURES" ) . is_some ( ) ;
1537
- // The secret key needed to get through the rustc build itself by
1538
- // subverting the unstable features lints
1539
- let bootstrap_secret_key = option_env ! ( "CFG_BOOTSTRAP_KEY" ) ;
1540
- // The matching key to the above, only known by the build system
1541
- let bootstrap_provided_key = env:: var ( "RUSTC_BOOTSTRAP_KEY" ) . ok ( ) ;
1542
- match ( disable_unstable_features, bootstrap_secret_key, bootstrap_provided_key) {
1543
- ( _, Some ( ref s) , Some ( ref p) ) if s == p => UnstableFeatures :: Cheat ,
1544
- ( true , ..) => UnstableFeatures :: Disallow ,
1545
- ( false , ..) => UnstableFeatures :: Allow
1546
- }
1547
- }
1548
-
1549
1533
pub fn parse_crate_types_from_list ( list_list : Vec < String > ) -> Result < Vec < CrateType > , String > {
1550
1534
let mut crate_types: Vec < CrateType > = Vec :: new ( ) ;
1551
1535
for unparsed_crate_type in & list_list {
@@ -1575,26 +1559,21 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
1575
1559
pub mod nightly_options {
1576
1560
use getopts;
1577
1561
use syntax:: feature_gate:: UnstableFeatures ;
1578
- use super :: { ErrorOutputType , OptionStability , RustcOptGroup , get_unstable_features_setting } ;
1562
+ use super :: { ErrorOutputType , OptionStability , RustcOptGroup } ;
1579
1563
use session:: { early_error, early_warn} ;
1580
1564
1581
1565
pub fn is_unstable_enabled ( matches : & getopts:: Matches ) -> bool {
1582
1566
is_nightly_build ( ) && matches. opt_strs ( "Z" ) . iter ( ) . any ( |x| * x == "unstable-options" )
1583
1567
}
1584
1568
1585
1569
pub fn is_nightly_build ( ) -> bool {
1586
- match get_unstable_features_setting ( ) {
1587
- UnstableFeatures :: Allow | UnstableFeatures :: Cheat => true ,
1588
- _ => false ,
1589
- }
1570
+ UnstableFeatures :: from_environment ( ) . is_nightly_build ( )
1590
1571
}
1591
1572
1592
1573
pub fn check_nightly_options ( matches : & getopts:: Matches , flags : & [ RustcOptGroup ] ) {
1593
1574
let has_z_unstable_option = matches. opt_strs ( "Z" ) . iter ( ) . any ( |x| * x == "unstable-options" ) ;
1594
- let really_allows_unstable_options = match get_unstable_features_setting ( ) {
1595
- UnstableFeatures :: Disallow => false ,
1596
- _ => true ,
1597
- } ;
1575
+ let really_allows_unstable_options = UnstableFeatures :: from_environment ( )
1576
+ . is_nightly_build ( ) ;
1598
1577
1599
1578
for opt in flags. iter ( ) {
1600
1579
if opt. stability == OptionStability :: Stable {
0 commit comments