From 69c900b8741147cfe7e23a6d944691820ef43e98 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Fri, 27 Dec 2024 10:18:10 -0500 Subject: [PATCH 1/2] Replace lazy_static with once_cell The ecosystem has largely moved from the former to the latter. --- Cargo.toml | 8 ++++---- src/runtest.rs | 6 +++--- tests/test_support/mod.rs | 23 +++++++++++------------ 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 67875a5..d5f0dc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,14 +20,14 @@ diff = "0.1.10" filetime = "0.2" getopts = "0.2" log = "0.4" +once_cell = "1.20" regex = "1.0" -tempfile = { version = "3.0", optional = true } +rustfix = "0.8" serde = "1.0" -serde_json = "1.0" serde_derive = "1.0" -rustfix = "0.8" +serde_json = "1.0" +tempfile = { version = "3.0", optional = true } tester = "0.9" -lazy_static = "1.4" [target."cfg(unix)".dependencies] libc = "0.2" diff --git a/src/runtest.rs b/src/runtest.rs index 775166c..69e89f5 100644 --- a/src/runtest.rs +++ b/src/runtest.rs @@ -21,6 +21,7 @@ use filetime::FileTime; use regex::Regex; use rustfix::{apply_suggestions, get_suggestions_from_json, Filter}; +use once_cell::sync::Lazy; use std::collections::HashMap; use std::collections::HashSet; use std::env; @@ -37,9 +38,8 @@ use std::sync::{Arc, Mutex, RwLock}; use crate::extract_gdb_version; fn get_or_create_coverage_file(path: &Path, create: impl FnOnce() -> File) -> Arc> { - lazy_static::lazy_static! { - static ref COVERAGE_FILE_LOCKS: RwLock>>> = RwLock::new(HashMap::new()); - } + static COVERAGE_FILE_LOCKS: Lazy>>>> = + Lazy::new(Default::default); { let locks = COVERAGE_FILE_LOCKS.read().unwrap(); diff --git a/tests/test_support/mod.rs b/tests/test_support/mod.rs index e775734..638f10c 100644 --- a/tests/test_support/mod.rs +++ b/tests/test_support/mod.rs @@ -2,6 +2,7 @@ //! //! Inspired by cargo's `cargo-test-support` crate: //! https://github.com/rust-lang/cargo/tree/master/crates/cargo-test-support +use once_cell::sync::Lazy; use std::cell::RefCell; use std::env; use std::fs; @@ -14,18 +15,16 @@ thread_local! { static TEST_ID: RefCell> = RefCell::new(None); } -lazy_static::lazy_static! { - pub static ref GLOBAL_ROOT: PathBuf = { - let mut path = env::current_exe().unwrap(); - path.pop(); // chop off exe name - path.pop(); // chop off 'deps' part - path.pop(); // chop off 'debug' - - path.push(COMPILETEST_INTEGRATION_TEST_DIR); - path.mkdir_p(); - path - }; -} +pub static GLOBAL_ROOT: Lazy = Lazy::new(|| { + let mut path = env::current_exe().unwrap(); + path.pop(); // chop off exe name + path.pop(); // chop off 'deps' part + path.pop(); // chop off 'debug' + + path.push(COMPILETEST_INTEGRATION_TEST_DIR); + path.mkdir_p(); + path +}); pub fn testsuite(mode: &str) -> TestsuiteBuilder { let builder = TestsuiteBuilder::new(mode); From 6b40285cba690f34848d8215707be4671627cdde Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Fri, 27 Dec 2024 10:23:53 -0500 Subject: [PATCH 2/2] `s/host_triple/host_tuple/` after 2024-11-03 See https://github.com/rust-lang/rust/commit/a26450cf81d67d68d3c6157579. --- Cargo.toml | 1 + src/common.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d5f0dc5..a318dee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ log = "0.4" once_cell = "1.20" regex = "1.0" rustfix = "0.8" +rustversion = "1.0" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" diff --git a/src/common.rs b/src/common.rs index d1b8e68..169a6db 100644 --- a/src/common.rs +++ b/src/common.rs @@ -415,10 +415,18 @@ mod config_tempdir { #[cfg(feature = "tmp")] pub use self::config_tempdir::ConfigWithTemp; +#[cfg(feature = "rustc")] +#[rustversion::since(2024-11-03)] +use rustc_session::config::host_tuple as host; + +#[cfg(feature = "rustc")] +#[rustversion::before(2024-11-03)] +use rustc_session::config::host_triple as host; + impl Default for Config { fn default() -> Config { #[cfg(feature = "rustc")] - let platform = rustc_session::config::host_triple().to_string(); + let platform = host().to_string(); Config { bless: false,