about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Hansch <dev@phansch.net>2020-10-06 08:20:18 +0200
committerPhilipp Hansch <dev@phansch.net>2020-10-06 08:20:18 +0200
commit9b4ceee5930e5a7118ac25a0f424a7f83d01980f (patch)
treecb83017d6612ce84c68a569bf7864de61dc680c6
parent4b459596a96a7d6f4797d4f1444311d88df60009 (diff)
downloadrust-9b4ceee5930e5a7118ac25a0f424a7f83d01980f.tar.gz
rust-9b4ceee5930e5a7118ac25a0f424a7f83d01980f.zip
integration tests: Replace lazy_static with SyncLazy
-rw-r--r--tests/cargo/mod.rs37
-rw-r--r--tests/compile-test.rs1
-rw-r--r--tests/dogfood.rs7
3 files changed, 21 insertions, 24 deletions
diff --git a/tests/cargo/mod.rs b/tests/cargo/mod.rs
index 3c385343f70..a8f3e3145f6 100644
--- a/tests/cargo/mod.rs
+++ b/tests/cargo/mod.rs
@@ -1,27 +1,24 @@
-use lazy_static::lazy_static;
 use std::env;
+use std::lazy::SyncLazy;
 use std::path::PathBuf;
 
-lazy_static! {
-    pub static ref CARGO_TARGET_DIR: PathBuf = {
-        match env::var_os("CARGO_TARGET_DIR") {
-            Some(v) => v.into(),
-            None => env::current_dir().unwrap().join("target"),
-        }
-    };
-    pub static ref TARGET_LIB: PathBuf = {
-        if let Some(path) = option_env!("TARGET_LIBS") {
-            path.into()
-        } else {
-            let mut dir = CARGO_TARGET_DIR.clone();
-            if let Some(target) = env::var_os("CARGO_BUILD_TARGET") {
-                dir.push(target);
-            }
-            dir.push(env!("PROFILE"));
-            dir
+pub static CARGO_TARGET_DIR: SyncLazy<PathBuf> = SyncLazy::new(|| match env::var_os("CARGO_TARGET_DIR") {
+    Some(v) => v.into(),
+    None => env::current_dir().unwrap().join("target"),
+});
+
+pub static TARGET_LIB: SyncLazy<PathBuf> = SyncLazy::new(|| {
+    if let Some(path) = option_env!("TARGET_LIBS") {
+        path.into()
+    } else {
+        let mut dir = CARGO_TARGET_DIR.clone();
+        if let Some(target) = env::var_os("CARGO_BUILD_TARGET") {
+            dir.push(target);
         }
-    };
-}
+        dir.push(env!("PROFILE"));
+        dir
+    }
+});
 
 #[must_use]
 pub fn is_rustc_test_suite() -> bool {
diff --git a/tests/compile-test.rs b/tests/compile-test.rs
index f0d73e9b0e2..0e8f7683103 100644
--- a/tests/compile-test.rs
+++ b/tests/compile-test.rs
@@ -1,4 +1,5 @@
 #![feature(test)] // compiletest_rs requires this attribute
+#![feature(once_cell)]
 
 use compiletest_rs as compiletest;
 use compiletest_rs::common::Mode as TestMode;
diff --git a/tests/dogfood.rs b/tests/dogfood.rs
index 81af3d3033b..48e0478f169 100644
--- a/tests/dogfood.rs
+++ b/tests/dogfood.rs
@@ -1,15 +1,14 @@
 // Dogfood cannot run on Windows
 #![cfg(not(windows))]
+#![feature(once_cell)]
 
-use lazy_static::lazy_static;
+use std::lazy::SyncLazy;
 use std::path::PathBuf;
 use std::process::Command;
 
 mod cargo;
 
-lazy_static! {
-    static ref CLIPPY_PATH: PathBuf = cargo::TARGET_LIB.join("cargo-clippy");
-}
+static CLIPPY_PATH: SyncLazy<PathBuf> = SyncLazy::new(|| cargo::TARGET_LIB.join("cargo-clippy"));
 
 #[test]
 fn dogfood_clippy() {