Move macro to separate module
This commit is contained in:
parent
4745cec7f3
commit
8b57668c33
@ -50,23 +50,6 @@ impl ConfigType for IgnoreList {
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if we're in a nightly build.
|
||||
///
|
||||
/// The environment variable `CFG_RELEASE_CHANNEL` is set during the rustc bootstrap
|
||||
/// to "stable", "beta", or "nightly" depending on what toolchain is being built.
|
||||
/// If we are being built as part of the stable or beta toolchains, we want
|
||||
/// to disable unstable configuration options.
|
||||
///
|
||||
/// 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.
|
||||
#[macro_export]
|
||||
macro_rules! is_nightly_channel {
|
||||
() => {
|
||||
option_env!("CFG_RELEASE_CHANNEL").map_or(true, |c| c == "nightly" || c == "dev")
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! create_config {
|
||||
($($i:ident: $ty:ty, $def:expr, $stb:expr, $( $dstring:expr ),+ );+ $(;)*) => (
|
||||
#[cfg(test)]
|
||||
@ -160,7 +143,7 @@ macro_rules! create_config {
|
||||
self.$i.1 = true;
|
||||
self.$i.2 = val;
|
||||
} else {
|
||||
if is_nightly_channel!() {
|
||||
if crate::is_nightly_channel!() {
|
||||
self.$i.1 = true;
|
||||
self.$i.2 = val;
|
||||
} else {
|
||||
|
@ -40,6 +40,9 @@ pub use crate::rustfmt_diff::{ModifiedChunk, ModifiedLines};
|
||||
#[macro_use]
|
||||
mod utils;
|
||||
|
||||
#[macro_use]
|
||||
mod release_channel;
|
||||
|
||||
mod attr;
|
||||
mod chains;
|
||||
pub(crate) mod checkstyle;
|
||||
|
16
src/release_channel.rs
Normal file
16
src/release_channel.rs
Normal file
@ -0,0 +1,16 @@
|
||||
/// Checks if we're in a nightly build.
|
||||
///
|
||||
/// The environment variable `CFG_RELEASE_CHANNEL` is set during the rustc bootstrap
|
||||
/// to "stable", "beta", or "nightly" depending on what toolchain is being built.
|
||||
/// If we are being built as part of the stable or beta toolchains, we want
|
||||
/// to disable unstable configuration options.
|
||||
///
|
||||
/// 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.
|
||||
#[macro_export]
|
||||
macro_rules! is_nightly_channel {
|
||||
() => {
|
||||
option_env!("CFG_RELEASE_CHANNEL").map_or(true, |c| c == "nightly" || c == "dev")
|
||||
};
|
||||
}
|
@ -11,10 +11,10 @@ use std::thread;
|
||||
|
||||
use crate::config::{Color, Config, EmitMode, FileName, NewlineStyle, ReportTactic};
|
||||
use crate::formatting::{ReportedErrors, SourceFile};
|
||||
use crate::is_nightly_channel;
|
||||
use crate::rustfmt_diff::{make_diff, print_diff, DiffLine, Mismatch, ModifiedChunk, OutputWriter};
|
||||
use crate::source_file;
|
||||
use crate::{FormatReport, FormatReportFormatterBuilder, Input, Session};
|
||||
use crate::is_nightly_channel;
|
||||
|
||||
const DIFF_CONTEXT_SIZE: usize = 3;
|
||||
const CONFIGURATIONS_FILE_NAME: &str = "Configurations.md";
|
||||
|
Loading…
x
Reference in New Issue
Block a user