Skip to content

Commit 99c96c5

Browse files
committed
driver: replace lazy_static by SyncLazy from std
1 parent 73a7204 commit 99c96c5

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -3439,7 +3439,6 @@ dependencies = [
34393439
name = "rustc_driver"
34403440
version = "0.0.0"
34413441
dependencies = [
3442-
"lazy_static",
34433442
"libc",
34443443
"rustc_ast",
34453444
"rustc_ast_pretty",

compiler/rustc_driver/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ edition = "2018"
88
crate-type = ["dylib"]
99

1010
[dependencies]
11-
lazy_static = "1.0"
1211
libc = "0.2"
1312
tracing = { version = "0.1.18", features = ["release_max_level_info"] }
1413
tracing-subscriber = { version = "0.2.10", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] }

compiler/rustc_driver/src/lib.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
#[macro_use]
1313
extern crate tracing;
14-
#[macro_use]
15-
extern crate lazy_static;
1614

1715
pub extern crate rustc_plugin_impl as plugin;
1816

@@ -49,6 +47,7 @@ use std::env;
4947
use std::ffi::OsString;
5048
use std::fs;
5149
use std::io::{self, Read, Write};
50+
use std::lazy::SyncLazy;
5251
use std::mem;
5352
use std::panic::{self, catch_unwind};
5453
use std::path::PathBuf;
@@ -1142,13 +1141,12 @@ pub fn catch_with_exit_code(f: impl FnOnce() -> interface::Result<()>) -> i32 {
11421141
}
11431142
}
11441143

1145-
lazy_static! {
1146-
static ref DEFAULT_HOOK: Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static> = {
1144+
static DEFAULT_HOOK: SyncLazy<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> =
1145+
SyncLazy::new(|| {
11471146
let hook = panic::take_hook();
11481147
panic::set_hook(Box::new(|info| report_ice(info, BUG_REPORT_URL)));
11491148
hook
1150-
};
1151-
}
1149+
});
11521150

11531151
/// Prints the ICE message, including backtrace and query stack.
11541152
///
@@ -1223,7 +1221,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
12231221
///
12241222
/// A custom rustc driver can skip calling this to set up a custom ICE hook.
12251223
pub fn install_ice_hook() {
1226-
lazy_static::initialize(&DEFAULT_HOOK);
1224+
SyncLazy::force(&DEFAULT_HOOK);
12271225
}
12281226

12291227
/// This allows tools to enable rust logging without having to magically match rustc's

compiler/rustc_feature/src/builtin_attrs.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -590,12 +590,13 @@ pub fn is_builtin_attr_name(name: Symbol) -> bool {
590590
BUILTIN_ATTRIBUTE_MAP.get(&name).is_some()
591591
}
592592

593-
pub static BUILTIN_ATTRIBUTE_MAP: SyncLazy<FxHashMap<Symbol, &'static BuiltinAttribute>> = SyncLazy::new(|| {
594-
let mut map = FxHashMap::default();
595-
for attr in BUILTIN_ATTRIBUTES.iter() {
596-
if map.insert(attr.0, attr).is_some() {
597-
panic!("duplicate builtin attribute `{}`", attr.0);
593+
pub static BUILTIN_ATTRIBUTE_MAP: SyncLazy<FxHashMap<Symbol, &'static BuiltinAttribute>> =
594+
SyncLazy::new(|| {
595+
let mut map = FxHashMap::default();
596+
for attr in BUILTIN_ATTRIBUTES.iter() {
597+
if map.insert(attr.0, attr).is_some() {
598+
panic!("duplicate builtin attribute `{}`", attr.0);
599+
}
598600
}
599-
}
600-
map
601-
});
601+
map
602+
});

0 commit comments

Comments
 (0)