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

This commit is contained in:
marmeladema 2020-09-01 21:42:21 +01:00
parent 67b8f9491c
commit 73a7204983
4 changed files with 12 additions and 13 deletions

View File

@ -3513,7 +3513,6 @@ dependencies = [
name = "rustc_feature"
version = "0.0.0"
dependencies = [
"lazy_static",
"rustc_data_structures",
"rustc_span",
]

View File

@ -9,5 +9,4 @@ doctest = false
[dependencies]
rustc_data_structures = { path = "../rustc_data_structures" }
lazy_static = "1.0.0"
rustc_span = { path = "../rustc_span" }

View File

@ -5,10 +5,11 @@ use AttributeType::*;
use crate::{Features, Stability};
use lazy_static::lazy_static;
use rustc_data_structures::fx::FxHashMap;
use rustc_span::symbol::{sym, Symbol};
use std::lazy::SyncLazy;
type GateFn = fn(&Features) -> bool;
macro_rules! cfg_fn {
@ -589,14 +590,12 @@ pub fn is_builtin_attr_name(name: Symbol) -> bool {
BUILTIN_ATTRIBUTE_MAP.get(&name).is_some()
}
lazy_static! {
pub static ref BUILTIN_ATTRIBUTE_MAP: FxHashMap<Symbol, &'static BuiltinAttribute> = {
let mut map = FxHashMap::default();
for attr in BUILTIN_ATTRIBUTES.iter() {
if map.insert(attr.0, attr).is_some() {
panic!("duplicate builtin attribute `{}`", attr.0);
}
pub static BUILTIN_ATTRIBUTE_MAP: SyncLazy<FxHashMap<Symbol, &'static BuiltinAttribute>> = SyncLazy::new(|| {
let mut map = FxHashMap::default();
for attr in BUILTIN_ATTRIBUTES.iter() {
if map.insert(attr.0, attr).is_some() {
panic!("duplicate builtin attribute `{}`", attr.0);
}
map
};
}
}
map
});

View File

@ -11,6 +11,8 @@
//! even if it is stabilized or removed, *do not remove it*. Instead, move the
//! symbol to the `accepted` or `removed` modules respectively.
#![feature(once_cell)]
mod accepted;
mod active;
mod builtin_attrs;