]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/src/release_channel.rs
Add 'src/tools/rustfmt/' from commit '7872306edf2e11a69aaffb9434088fd66b46a863'
[rust.git] / src / tools / rustfmt / src / release_channel.rs
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]
12 macro_rules! is_nightly_channel {
13     () => {
14         option_env!("CFG_RELEASE_CHANNEL").map_or(true, |c| c == "nightly" || c == "dev")
15     };
16 }