提交 67b8f949 编写于 作者: M marmeladema

hir: replace `lazy_static` by `SyncLazy` from std

上级 1b650d0f
...@@ -3530,7 +3530,6 @@ version = "0.0.0" ...@@ -3530,7 +3530,6 @@ version = "0.0.0"
name = "rustc_hir" name = "rustc_hir"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"lazy_static",
"rustc_ast", "rustc_ast",
"rustc_data_structures", "rustc_data_structures",
"rustc_index", "rustc_index",
......
...@@ -15,6 +15,5 @@ rustc_index = { path = "../rustc_index" } ...@@ -15,6 +15,5 @@ rustc_index = { path = "../rustc_index" }
rustc_span = { path = "../rustc_span" } rustc_span = { path = "../rustc_span" }
rustc_serialize = { path = "../rustc_serialize" } rustc_serialize = { path = "../rustc_serialize" }
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
lazy_static = "1"
tracing = "0.1" tracing = "0.1"
smallvec = { version = "1.0", features = ["union", "may_dangle"] } smallvec = { version = "1.0", features = ["union", "may_dangle"] }
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::Span; use rustc_span::Span;
use lazy_static::lazy_static; use std::lazy::SyncLazy;
pub enum LangItemGroup { pub enum LangItemGroup {
Op, Op,
...@@ -117,14 +117,12 @@ pub fn $method(&self) -> Option<DefId> { ...@@ -117,14 +117,12 @@ pub fn $method(&self) -> Option<DefId> {
)* )*
} }
lazy_static! { /// A mapping from the name of the lang item to its order and the form it must be of.
/// A mapping from the name of the lang item to its order and the form it must be of. pub static ITEM_REFS: SyncLazy<FxHashMap<Symbol, (usize, Target)>> = SyncLazy::new(|| {
pub static ref ITEM_REFS: FxHashMap<Symbol, (usize, Target)> = { let mut item_refs = FxHashMap::default();
let mut item_refs = FxHashMap::default(); $( item_refs.insert($name, (LangItem::$variant as usize, $target)); )*
$( item_refs.insert($name, (LangItem::$variant as usize, $target)); )* item_refs
item_refs });
};
}
// End of the macro // End of the macro
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#![feature(const_fn)] // For the unsizing cast on `&[]` #![feature(const_fn)] // For the unsizing cast on `&[]`
#![feature(const_panic)] #![feature(const_panic)]
#![feature(in_band_lifetimes)] #![feature(in_band_lifetimes)]
#![feature(once_cell)]
#![feature(or_patterns)] #![feature(or_patterns)]
#![recursion_limit = "256"] #![recursion_limit = "256"]
......
...@@ -7,18 +7,16 @@ ...@@ -7,18 +7,16 @@
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_span::symbol::{sym, Symbol}; use rustc_span::symbol::{sym, Symbol};
use lazy_static::lazy_static; use std::lazy::SyncLazy;
macro_rules! weak_lang_items { macro_rules! weak_lang_items {
($($name:ident, $item:ident, $sym:ident;)*) => ( ($($name:ident, $item:ident, $sym:ident;)*) => (
lazy_static! { pub static WEAK_ITEMS_REFS: SyncLazy<FxHashMap<Symbol, LangItem>> = SyncLazy::new(|| {
pub static ref WEAK_ITEMS_REFS: FxHashMap<Symbol, LangItem> = { let mut map = FxHashMap::default();
let mut map = FxHashMap::default(); $(map.insert(sym::$name, LangItem::$item);)*
$(map.insert(sym::$name, LangItem::$item);)* map
map });
};
}
/// The `check_name` argument avoids the need for `librustc_hir` to depend on /// The `check_name` argument avoids the need for `librustc_hir` to depend on
/// `librustc_session`. /// `librustc_session`.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册