feature: replace lazy_static
by SyncLazy
from std
This commit is contained in:
parent
67b8f9491c
commit
73a7204983
4 changed files with 12 additions and 13 deletions
|
@ -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
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue