diff --git a/Cargo.lock b/Cargo.lock index 8158ebeeba2..e5611f1f0d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2938,7 +2938,7 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustfix" -version = "0.8.3" +version = "0.8.4" dependencies = [ "anyhow", "proptest", diff --git a/crates/rustfix/Cargo.toml b/crates/rustfix/Cargo.toml index 533d028d95d..1f9b61cd5e2 100644 --- a/crates/rustfix/Cargo.toml +++ b/crates/rustfix/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustfix" -version = "0.8.3" +version = "0.8.4" authors = [ "Pascal Hertleif ", "Oliver Schneider ", diff --git a/crates/rustfix/tests/everything/multiple-solutions.fixed.rs b/crates/rustfix/tests/everything/multiple-solutions.nightly.fixed.rs similarity index 54% rename from crates/rustfix/tests/everything/multiple-solutions.fixed.rs rename to crates/rustfix/tests/everything/multiple-solutions.nightly.fixed.rs index 1a261785d77..50ccab26b81 100644 --- a/crates/rustfix/tests/everything/multiple-solutions.fixed.rs +++ b/crates/rustfix/tests/everything/multiple-solutions.nightly.fixed.rs @@ -1,4 +1,4 @@ -use std::collections::{HashSet}; +use std::collections::HashSet; fn main() { let _: HashSet<()>; diff --git a/crates/rustfix/tests/everything/multiple-solutions.json b/crates/rustfix/tests/everything/multiple-solutions.nightly.json similarity index 55% rename from crates/rustfix/tests/everything/multiple-solutions.json rename to crates/rustfix/tests/everything/multiple-solutions.nightly.json index 89b14ccc848..ce9d54e4a84 100644 --- a/crates/rustfix/tests/everything/multiple-solutions.json +++ b/crates/rustfix/tests/everything/multiple-solutions.nightly.json @@ -1,4 +1,5 @@ { + "$message_type": "diagnostic", "message": "unused imports: `HashMap`, `VecDeque`", "code": { "code": "unused_imports", @@ -7,7 +8,7 @@ "level": "warning", "spans": [ { - "file_name": "src/main.rs", + "file_name": "./tests/everything/multiple-solutions.nightly.rs", "byte_start": 23, "byte_end": 30, "line_start": 1, @@ -28,7 +29,7 @@ "expansion": null }, { - "file_name": "src/main.rs", + "file_name": "./tests/everything/multiple-solutions.nightly.rs", "byte_start": 41, "byte_end": 49, "line_start": 1, @@ -51,7 +52,7 @@ ], "children": [ { - "message": "#[warn(unused_imports)] on by default", + "message": "`#[warn(unused_imports)]` on by default", "code": null, "level": "note", "spans": [], @@ -64,7 +65,28 @@ "level": "help", "spans": [ { - "file_name": "src/main.rs", + "file_name": "./tests/everything/multiple-solutions.nightly.rs", + "byte_start": 22, + "byte_end": 23, + "line_start": 1, + "line_end": 1, + "column_start": 23, + "column_end": 24, + "is_primary": true, + "text": [ + { + "text": "use std::collections::{HashMap, HashSet, VecDeque};", + "highlight_start": 23, + "highlight_end": 24 + } + ], + "label": null, + "suggested_replacement": "", + "suggestion_applicability": "MachineApplicable", + "expansion": null + }, + { + "file_name": "./tests/everything/multiple-solutions.nightly.rs", "byte_start": 23, "byte_end": 32, "line_start": 1, @@ -85,7 +107,7 @@ "expansion": null }, { - "file_name": "src/main.rs", + "file_name": "./tests/everything/multiple-solutions.nightly.rs", "byte_start": 39, "byte_end": 49, "line_start": 1, @@ -104,11 +126,41 @@ "suggested_replacement": "", "suggestion_applicability": "MachineApplicable", "expansion": null + }, + { + "file_name": "./tests/everything/multiple-solutions.nightly.rs", + "byte_start": 49, + "byte_end": 50, + "line_start": 1, + "line_end": 1, + "column_start": 50, + "column_end": 51, + "is_primary": true, + "text": [ + { + "text": "use std::collections::{HashMap, HashSet, VecDeque};", + "highlight_start": 50, + "highlight_end": 51 + } + ], + "label": null, + "suggested_replacement": "", + "suggestion_applicability": "MachineApplicable", + "expansion": null } ], "children": [], "rendered": null } ], - "rendered": "warning: unused imports: `HashMap`, `VecDeque`\n --> src/main.rs:1:24\n |\n1 | use std::collections::{HashMap, HashSet, VecDeque};\n | ^^^^^^^ ^^^^^^^^\n |\n = note: #[warn(unused_imports)] on by default\nhelp: remove the unused imports\n |\n1 | use std::collections::{HashSet};\n | -- --\n\n" + "rendered": "warning: unused imports: `HashMap`, `VecDeque`\n --> ./tests/everything/multiple-solutions.nightly.rs:1:24\n |\n1 | use std::collections::{HashMap, HashSet, VecDeque};\n | ^^^^^^^ ^^^^^^^^\n |\n = note: `#[warn(unused_imports)]` on by default\n\n" +} +{ + "$message_type": "diagnostic", + "message": "1 warning emitted", + "code": null, + "level": "warning", + "spans": [], + "children": [], + "rendered": "warning: 1 warning emitted\n\n" } diff --git a/crates/rustfix/tests/everything/multiple-solutions.rs b/crates/rustfix/tests/everything/multiple-solutions.nightly.rs similarity index 100% rename from crates/rustfix/tests/everything/multiple-solutions.rs rename to crates/rustfix/tests/everything/multiple-solutions.nightly.rs diff --git a/crates/rustfix/tests/parse_and_replace.rs b/crates/rustfix/tests/parse_and_replace.rs index 949903b238f..7bb11d33239 100644 --- a/crates/rustfix/tests/parse_and_replace.rs +++ b/crates/rustfix/tests/parse_and_replace.rs @@ -45,6 +45,26 @@ mod settings { pub const BLESS: &str = "RUSTFIX_TEST_BLESS"; } +static mut VERSION: (u32, bool) = (0, false); + +// Temporarily copy from `cargo_test_macro::version`. +fn version() -> (u32, bool) { + static INIT: std::sync::Once = std::sync::Once::new(); + INIT.call_once(|| { + let output = Command::new("rustc") + .arg("-V") + .output() + .expect("cargo should run"); + let stdout = std::str::from_utf8(&output.stdout).expect("utf8"); + let vers = stdout.split_whitespace().skip(1).next().unwrap(); + let is_nightly = option_env!("CARGO_TEST_DISABLE_NIGHTLY").is_none() + && (vers.contains("-nightly") || vers.contains("-dev")); + let minor = vers.split('.').skip(1).next().unwrap().parse().unwrap(); + unsafe { VERSION = (minor, is_nightly) } + }); + unsafe { VERSION } +} + fn compile(file: &Path) -> Result { let tmp = tempdir()?; @@ -220,7 +240,20 @@ fn assert_fixtures(dir: &str, mode: &str) { .unwrap(); let mut failures = 0; + let is_not_nightly = !version().1; + for file in &files { + if file + .file_stem() + .unwrap() + .to_str() + .unwrap() + .ends_with(".nightly") + && is_not_nightly + { + info!("skipped: {file:?}"); + continue; + } if let Err(err) = test_rustfix_with_file(file, mode) { println!("failed: {}", file.display()); warn!("{:?}", err);