]> git.proxmox.com Git - rustc.git/blame - src/tools/rustfmt/src/release_channel.rs
New upstream version 1.52.1+dfsg1
[rustc.git] / src / tools / rustfmt / src / release_channel.rs
CommitLineData
f20569fa
XL
1/// Checks if we're in a nightly build.
2///
3/// The environment variable `CFG_RELEASE_CHANNEL` is set during the rustc bootstrap
4/// to "stable", "beta", or "nightly" depending on what toolchain is being built.
5/// If we are being built as part of the stable or beta toolchains, we want
6/// to disable unstable configuration options.
7///
8/// If we're being built by cargo (e.g., `cargo +nightly install rustfmt-nightly`),
9/// `CFG_RELEASE_CHANNEL` is not set. As we only support being built against the
10/// nightly compiler when installed from crates.io, default to nightly mode.
11#[macro_export]
12macro_rules! is_nightly_channel {
13 () => {
14 option_env!("CFG_RELEASE_CHANNEL").map_or(true, |c| c == "nightly" || c == "dev")
15 };
16}