From 25102cc263104dc5cb028b8c0d9b0f3572534c92 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 2 Nov 2019 08:01:54 -0700 Subject: [PATCH] Allow RUSTFMT_BOOTSTRAP=1 to override nightly feature checks. This was recommended in https://github.com/rust-lang/rust/pull/65939#discussion_r341424553. --- src/release_channel.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/release_channel.rs b/src/release_channel.rs index 05a7e91ce5c..781c0a964b8 100644 --- a/src/release_channel.rs +++ b/src/release_channel.rs @@ -8,6 +8,10 @@ /// If we're being built by cargo (e.g., `cargo +nightly install rustfmt-nightly`), /// `CFG_RELEASE_CHANNEL` is not set. As we only support being built against the /// nightly compiler when installed from crates.io, default to nightly mode. +/// +/// Additionally, the RUSTFMT_BOOTSTRAP environment variable can be set to `1` to +/// allow for use of unstable features when used within the compiler's stage0. pub fn is_nightly() -> bool { option_env!("CFG_RELEASE_CHANNEL").map_or(true, |c| c == "nightly" || c == "dev") + || std::env::var("RUSTFMT_BOOTSTRAP") == Ok("1".to_string()) }