Skip to content

Commit 67b8f94

Browse files
committed
hir: replace lazy_static by SyncLazy from std
1 parent 1b650d0 commit 67b8f94

File tree

5 files changed

+14
-19
lines changed

5 files changed

+14
-19
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -3530,7 +3530,6 @@ version = "0.0.0"
35303530
name = "rustc_hir"
35313531
version = "0.0.0"
35323532
dependencies = [
3533-
"lazy_static",
35343533
"rustc_ast",
35353534
"rustc_data_structures",
35363535
"rustc_index",

compiler/rustc_hir/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ rustc_index = { path = "../rustc_index" }
1515
rustc_span = { path = "../rustc_span" }
1616
rustc_serialize = { path = "../rustc_serialize" }
1717
rustc_ast = { path = "../rustc_ast" }
18-
lazy_static = "1"
1918
tracing = "0.1"
2019
smallvec = { version = "1.0", features = ["union", "may_dangle"] }

compiler/rustc_hir/src/lang_items.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_macros::HashStable_Generic;
1717
use rustc_span::symbol::{kw, sym, Symbol};
1818
use rustc_span::Span;
1919

20-
use lazy_static::lazy_static;
20+
use std::lazy::SyncLazy;
2121

2222
pub enum LangItemGroup {
2323
Op,
@@ -117,14 +117,12 @@ macro_rules! language_item_table {
117117
)*
118118
}
119119

120-
lazy_static! {
121-
/// A mapping from the name of the lang item to its order and the form it must be of.
122-
pub static ref ITEM_REFS: FxHashMap<Symbol, (usize, Target)> = {
123-
let mut item_refs = FxHashMap::default();
124-
$( item_refs.insert($name, (LangItem::$variant as usize, $target)); )*
125-
item_refs
126-
};
127-
}
120+
/// A mapping from the name of the lang item to its order and the form it must be of.
121+
pub static ITEM_REFS: SyncLazy<FxHashMap<Symbol, (usize, Target)>> = SyncLazy::new(|| {
122+
let mut item_refs = FxHashMap::default();
123+
$( item_refs.insert($name, (LangItem::$variant as usize, $target)); )*
124+
item_refs
125+
});
128126

129127
// End of the macro
130128
}

compiler/rustc_hir/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![feature(const_fn)] // For the unsizing cast on `&[]`
77
#![feature(const_panic)]
88
#![feature(in_band_lifetimes)]
9+
#![feature(once_cell)]
910
#![feature(or_patterns)]
1011
#![recursion_limit = "256"]
1112

compiler/rustc_hir/src/weak_lang_items.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@ use rustc_ast as ast;
77
use rustc_data_structures::fx::FxHashMap;
88
use rustc_span::symbol::{sym, Symbol};
99

10-
use lazy_static::lazy_static;
10+
use std::lazy::SyncLazy;
1111

1212
macro_rules! weak_lang_items {
1313
($($name:ident, $item:ident, $sym:ident;)*) => (
1414

15-
lazy_static! {
16-
pub static ref WEAK_ITEMS_REFS: FxHashMap<Symbol, LangItem> = {
17-
let mut map = FxHashMap::default();
18-
$(map.insert(sym::$name, LangItem::$item);)*
19-
map
20-
};
21-
}
15+
pub static WEAK_ITEMS_REFS: SyncLazy<FxHashMap<Symbol, LangItem>> = SyncLazy::new(|| {
16+
let mut map = FxHashMap::default();
17+
$(map.insert(sym::$name, LangItem::$item);)*
18+
map
19+
});
2220

2321
/// The `check_name` argument avoids the need for `librustc_hir` to depend on
2422
/// `librustc_session`.

0 commit comments

Comments
 (0)