Skip to content

Commit 098e4f1

Browse files
committed
driver.rs: Replace lazy_static with once_cell
1 parent c5774f9 commit 098e4f1

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ clippy_lints = { version = "0.0.212", path = "clippy_lints" }
3434
semver = "0.10"
3535
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
3636
tempfile = { version = "3.1.0", optional = true }
37-
lazy_static = "1.0"
3837

3938
[dev-dependencies]
4039
cargo_metadata = "0.11.1"
4140
compiletest_rs = { version = "0.5.0", features = ["tmp"] }
4241
tester = "0.7"
43-
lazy_static = "1.0"
4442
clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }
4543
serde = { version = "1.0", features = ["derive"] }
4644
derive-new = "0.5"

src/driver.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ use rustc_interface::interface;
1818
use rustc_middle::ty::TyCtxt;
1919
use rustc_tools_util::VersionInfo;
2020

21-
use lazy_static::lazy_static;
2221
use std::borrow::Cow;
2322
use std::env;
2423
use std::ops::Deref;
2524
use std::panic;
2625
use std::path::{Path, PathBuf};
2726
use std::process::{exit, Command};
27+
use std::lazy::SyncLazy;
2828

2929
mod lintlist;
3030

@@ -231,13 +231,11 @@ You can use tool lints to allow or deny lints from your code, eg.:
231231

232232
const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust-clippy/issues/new";
233233

234-
lazy_static! {
235-
static ref ICE_HOOK: Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static> = {
236-
let hook = panic::take_hook();
237-
panic::set_hook(Box::new(|info| report_clippy_ice(info, BUG_REPORT_URL)));
238-
hook
239-
};
240-
}
234+
static ICE_HOOK: SyncLazy<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> = SyncLazy::new(|| {
235+
let hook = panic::take_hook();
236+
panic::set_hook(Box::new(|info| report_clippy_ice(info, BUG_REPORT_URL)));
237+
hook
238+
});
241239

242240
fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
243241
// 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
296294

297295
pub fn main() {
298296
rustc_driver::init_rustc_env_logger();
299-
lazy_static::initialize(&ICE_HOOK);
297+
SyncLazy::force(&ICE_HOOK);
300298
exit(rustc_driver::catch_with_exit_code(move || {
301299
let mut orig_args: Vec<String> = env::args().collect();
302300

0 commit comments

Comments
 (0)