about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Hansch <dev@phansch.net>2020-10-12 18:29:29 +0200
committerPhilipp Hansch <dev@phansch.net>2020-10-12 18:29:29 +0200
commit098e4f119595cc199bf09ccf150aeefa6b2c49ac (patch)
tree286520a867ab11773f94dc3e4e9da2a74bfa0a42
parentc5774f94efd60b60fc7120ba3d6de7f79b05681b (diff)
downloadrust-098e4f119595cc199bf09ccf150aeefa6b2c49ac.tar.gz
rust-098e4f119595cc199bf09ccf150aeefa6b2c49ac.zip
driver.rs: Replace lazy_static with once_cell
-rw-r--r--Cargo.toml2
-rw-r--r--src/driver.rs16
2 files changed, 7 insertions, 11 deletions
diff --git a/Cargo.toml b/Cargo.toml
index c7a3099b8ab..13db35f4b0e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -34,13 +34,11 @@ clippy_lints = { version = "0.0.212", path = "clippy_lints" }
 semver = "0.10"
 rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
 tempfile = { version = "3.1.0", optional = true }
-lazy_static = "1.0"
 
 [dev-dependencies]
 cargo_metadata = "0.11.1"
 compiletest_rs = { version = "0.5.0", features = ["tmp"] }
 tester = "0.7"
-lazy_static = "1.0"
 clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }
 serde = { version = "1.0", features = ["derive"] }
 derive-new = "0.5"
diff --git a/src/driver.rs b/src/driver.rs
index c9b07855af1..e32ba116939 100644
--- a/src/driver.rs
+++ b/src/driver.rs
@@ -18,13 +18,13 @@ use rustc_interface::interface;
 use rustc_middle::ty::TyCtxt;
 use rustc_tools_util::VersionInfo;
 
-use lazy_static::lazy_static;
 use std::borrow::Cow;
 use std::env;
 use std::ops::Deref;
 use std::panic;
 use std::path::{Path, PathBuf};
 use std::process::{exit, Command};
+use std::lazy::SyncLazy;
 
 mod lintlist;
 
@@ -231,13 +231,11 @@ You can use tool lints to allow or deny lints from your code, eg.:
 
 const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust-clippy/issues/new";
 
-lazy_static! {
-    static ref ICE_HOOK: Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static> = {
-        let hook = panic::take_hook();
-        panic::set_hook(Box::new(|info| report_clippy_ice(info, BUG_REPORT_URL)));
-        hook
-    };
-}
+static ICE_HOOK: SyncLazy<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> = SyncLazy::new(|| {
+    let hook = panic::take_hook();
+    panic::set_hook(Box::new(|info| report_clippy_ice(info, BUG_REPORT_URL)));
+    hook
+});
 
 fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
     // Invoke our ICE handler, which prints the actual panic message and optionally a backtrace
@@ -296,7 +294,7 @@ fn toolchain_path(home: Option<String>, toolchain: Option<String>) -> Option<Pat
 
 pub fn main() {
     rustc_driver::init_rustc_env_logger();
-    lazy_static::initialize(&ICE_HOOK);
+    SyncLazy::force(&ICE_HOOK);
     exit(rustc_driver::catch_with_exit_code(move || {
         let mut orig_args: Vec<String> = env::args().collect();