Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 8b57668

Browse files
author
Ruben Schmidmeister
committed
Move macro to separate module
1 parent 4745cec commit 8b57668

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

src/config/config_type.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,6 @@ impl ConfigType for IgnoreList {
5050
}
5151
}
5252

53-
/// Checks if we're in a nightly build.
54-
///
55-
/// The environment variable `CFG_RELEASE_CHANNEL` is set during the rustc bootstrap
56-
/// to "stable", "beta", or "nightly" depending on what toolchain is being built.
57-
/// If we are being built as part of the stable or beta toolchains, we want
58-
/// to disable unstable configuration options.
59-
///
60-
/// If we're being built by cargo (e.g., `cargo +nightly install rustfmt-nightly`),
61-
/// `CFG_RELEASE_CHANNEL` is not set. As we only support being built against the
62-
/// nightly compiler when installed from crates.io, default to nightly mode.
63-
#[macro_export]
64-
macro_rules! is_nightly_channel {
65-
() => {
66-
option_env!("CFG_RELEASE_CHANNEL").map_or(true, |c| c == "nightly" || c == "dev")
67-
};
68-
}
69-
7053
macro_rules! create_config {
7154
($($i:ident: $ty:ty, $def:expr, $stb:expr, $( $dstring:expr ),+ );+ $(;)*) => (
7255
#[cfg(test)]
@@ -160,7 +143,7 @@ macro_rules! create_config {
160143
self.$i.1 = true;
161144
self.$i.2 = val;
162145
} else {
163-
if is_nightly_channel!() {
146+
if crate::is_nightly_channel!() {
164147
self.$i.1 = true;
165148
self.$i.2 = val;
166149
} else {

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ pub use crate::rustfmt_diff::{ModifiedChunk, ModifiedLines};
4040
#[macro_use]
4141
mod utils;
4242

43+
#[macro_use]
44+
mod release_channel;
45+
4346
mod attr;
4447
mod chains;
4548
pub(crate) mod checkstyle;

src/release_channel.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
}

src/test/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use std::thread;
1111

1212
use crate::config::{Color, Config, EmitMode, FileName, NewlineStyle, ReportTactic};
1313
use crate::formatting::{ReportedErrors, SourceFile};
14+
use crate::is_nightly_channel;
1415
use crate::rustfmt_diff::{make_diff, print_diff, DiffLine, Mismatch, ModifiedChunk, OutputWriter};
1516
use crate::source_file;
1617
use crate::{FormatReport, FormatReportFormatterBuilder, Input, Session};
17-
use crate::is_nightly_channel;
1818

1919
const DIFF_CONTEXT_SIZE: usize = 3;
2020
const CONFIGURATIONS_FILE_NAME: &str = "Configurations.md";

0 commit comments

Comments
 (0)