about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRuben Schmidmeister <ruben.schmidmeister@icloud.com>2019-05-17 16:07:49 +0200
committerRuben Schmidmeister <ruben.schmidmeister@icloud.com>2019-05-17 16:07:49 +0200
commit4745cec7f3a016d48c86c67bb6b41b3d434cd28e (patch)
treefeff414f913551092f5fd8e807b0e248d606d5d4 /src
parentfd22c27c47a71cff2f92e61b11b3344ed9e50d25 (diff)
Re-use nightly channel macro
Diffstat (limited to 'src')
-rw-r--r--src/config/config_type.rs1
-rw-r--r--src/test/mod.rs12
2 files changed, 5 insertions, 8 deletions
diff --git a/src/config/config_type.rs b/src/config/config_type.rs
index d14969418ad..26cd672f83a 100644
--- a/src/config/config_type.rs
+++ b/src/config/config_type.rs
@@ -60,6 +60,7 @@ impl ConfigType for IgnoreList {
 /// 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")
diff --git a/src/test/mod.rs b/src/test/mod.rs
index 101a8c07fd9..d3e18130977 100644
--- a/src/test/mod.rs
+++ b/src/test/mod.rs
@@ -14,6 +14,7 @@ use crate::formatting::{ReportedErrors, SourceFile};
 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";
@@ -260,7 +261,7 @@ fn assert_output(source: &Path, expected_filename: &Path) {
 fn idempotence_tests() {
     run_test_with(&TestSetting::default(), || {
         // these tests require nightly
-        if !is_nightly() {
+        if !is_nightly_channel!() {
             return;
         }
         // Get all files in the tests/target directory.
@@ -278,7 +279,7 @@ fn idempotence_tests() {
 #[test]
 fn self_tests() {
     // Issue-3443: these tests require nightly
-    if !is_nightly() {
+    if !is_nightly_channel!() {
         return;
     }
     let mut files = get_test_files(Path::new("tests"), false);
@@ -313,11 +314,6 @@ fn self_tests() {
     );
 }
 
-fn is_nightly() -> bool {
-    let release_channel = option_env!("CFG_RELEASE_CHANNEL");
-    release_channel.is_none() || release_channel == Some("nightly")
-}
-
 #[test]
 fn stdin_formatting_smoke_test() {
     let input = Input::Text("fn main () {}".to_owned());
@@ -432,7 +428,7 @@ fn check_files(files: Vec<PathBuf>, opt_config: &Option<PathBuf>) -> (Vec<Format
 
     for file_name in files {
         let sig_comments = read_significant_comments(&file_name);
-        if sig_comments.contains_key("unstable") && !is_nightly() {
+        if sig_comments.contains_key("unstable") && !is_nightly_channel!() {
             debug!(
                 "Skipping '{}' because it requires unstable \
                  features which are only available on nightly...",