From 2c76ee978758116bce3e8541568812420fa1bb32 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 18 Oct 2016 22:13:13 -0700 Subject: [PATCH] Let any bootstrap key suffice to allow features This is a follow-up to pull request #32812, according to the new decision in issue #36548 to relax bootstrap key logic. Now *any* non-empty bootstrap key is allowed to circumvent the feature gate. For now, the build system still goes through the same motions to set RUSTC_BOOTSTRAP_KEY according to the prior system. This is necessary at least until the next stage0 base includes this relaxed key check. It also makes it simpler to revert this if we change our mind. --- src/libsyntax/feature_gate.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 62b88888fc878..2391546d0023e 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1317,15 +1317,13 @@ impl UnstableFeatures { pub fn from_environment() -> UnstableFeatures { // Whether 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(); - // The secret key needed to get through the rustc build itself by - // subverting the unstable features lints - let bootstrap_secret_key = option_env!("CFG_BOOTSTRAP_KEY"); - // The matching key to the above, only known by the build system - let bootstrap_provided_key = env::var("RUSTC_BOOTSTRAP_KEY").ok(); - match (disable_unstable_features, bootstrap_secret_key, bootstrap_provided_key) { - (_, Some(ref s), Some(ref p)) if s == p => UnstableFeatures::Cheat, - (true, _, _) => UnstableFeatures::Disallow, - (false, _, _) => UnstableFeatures::Allow + // Check whether we want to circumvent the unstable feature kill-switch for bootstrap + let bootstrap_circumvent = env::var_os("RUSTC_BOOTSTRAP_KEY") + .map_or(false, |e| !e.is_empty()); + match (disable_unstable_features, bootstrap_circumvent) { + (_, true) => UnstableFeatures::Cheat, + (true, _) => UnstableFeatures::Disallow, + (false, _) => UnstableFeatures::Allow } }