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

Commit 4745cec

Browse files
author
Ruben Schmidmeister
committed
Re-use nightly channel macro
1 parent fd22c27 commit 4745cec

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/config/config_type.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ impl ConfigType for IgnoreList {
6060
/// If we're being built by cargo (e.g., `cargo +nightly install rustfmt-nightly`),
6161
/// `CFG_RELEASE_CHANNEL` is not set. As we only support being built against the
6262
/// nightly compiler when installed from crates.io, default to nightly mode.
63+
#[macro_export]
6364
macro_rules! is_nightly_channel {
6465
() => {
6566
option_env!("CFG_RELEASE_CHANNEL").map_or(true, |c| c == "nightly" || c == "dev")

src/test/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::formatting::{ReportedErrors, SourceFile};
1414
use crate::rustfmt_diff::{make_diff, print_diff, DiffLine, Mismatch, ModifiedChunk, OutputWriter};
1515
use crate::source_file;
1616
use crate::{FormatReport, FormatReportFormatterBuilder, Input, Session};
17+
use crate::is_nightly_channel;
1718

1819
const DIFF_CONTEXT_SIZE: usize = 3;
1920
const CONFIGURATIONS_FILE_NAME: &str = "Configurations.md";
@@ -260,7 +261,7 @@ fn assert_output(source: &Path, expected_filename: &Path) {
260261
fn idempotence_tests() {
261262
run_test_with(&TestSetting::default(), || {
262263
// these tests require nightly
263-
if !is_nightly() {
264+
if !is_nightly_channel!() {
264265
return;
265266
}
266267
// Get all files in the tests/target directory.
@@ -278,7 +279,7 @@ fn idempotence_tests() {
278279
#[test]
279280
fn self_tests() {
280281
// Issue-3443: these tests require nightly
281-
if !is_nightly() {
282+
if !is_nightly_channel!() {
282283
return;
283284
}
284285
let mut files = get_test_files(Path::new("tests"), false);
@@ -313,11 +314,6 @@ fn self_tests() {
313314
);
314315
}
315316

316-
fn is_nightly() -> bool {
317-
let release_channel = option_env!("CFG_RELEASE_CHANNEL");
318-
release_channel.is_none() || release_channel == Some("nightly")
319-
}
320-
321317
#[test]
322318
fn stdin_formatting_smoke_test() {
323319
let input = Input::Text("fn main () {}".to_owned());
@@ -432,7 +428,7 @@ fn check_files(files: Vec<PathBuf>, opt_config: &Option<PathBuf>) -> (Vec<Format
432428

433429
for file_name in files {
434430
let sig_comments = read_significant_comments(&file_name);
435-
if sig_comments.contains_key("unstable") && !is_nightly() {
431+
if sig_comments.contains_key("unstable") && !is_nightly_channel!() {
436432
debug!(
437433
"Skipping '{}' because it requires unstable \
438434
features which are only available on nightly...",

0 commit comments

Comments
 (0)