diff options
| author | marmeladema <xademax@gmail.com> | 2020-09-01 21:42:21 +0100 |
|---|---|---|
| committer | marmeladema <xademax@gmail.com> | 2020-09-01 22:06:47 +0100 |
| commit | 73a7204983a28177b296a3dcd8632540a6fcee1a (patch) | |
| tree | 5c6ad27850e402ee4845b6360e208b14055d52f0 | |
| parent | 67b8f9491c30cba0e4892f6b5b8bda8b312428da (diff) | |
| download | rust-73a7204983a28177b296a3dcd8632540a6fcee1a.tar.gz rust-73a7204983a28177b296a3dcd8632540a6fcee1a.zip | |
feature: replace `lazy_static` by `SyncLazy` from std
| -rw-r--r-- | Cargo.lock | 1 | ||||
| -rw-r--r-- | compiler/rustc_feature/Cargo.toml | 1 | ||||
| -rw-r--r-- | compiler/rustc_feature/src/builtin_attrs.rs | 21 | ||||
| -rw-r--r-- | compiler/rustc_feature/src/lib.rs | 2 |
4 files changed, 12 insertions, 13 deletions
diff --git a/Cargo.lock b/Cargo.lock index 3cc5aec6cac..f4a8855b4c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3513,7 +3513,6 @@ dependencies = [ name = "rustc_feature" version = "0.0.0" dependencies = [ - "lazy_static", "rustc_data_structures", "rustc_span", ] diff --git a/compiler/rustc_feature/Cargo.toml b/compiler/rustc_feature/Cargo.toml index 3f8047e931e..7a06bce13c8 100644 --- a/compiler/rustc_feature/Cargo.toml +++ b/compiler/rustc_feature/Cargo.toml @@ -9,5 +9,4 @@ doctest = false [dependencies] rustc_data_structures = { path = "../rustc_data_structures" } -lazy_static = "1.0.0" rustc_span = { path = "../rustc_span" } diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 879f06f89a7..5d1b1bde84a 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -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 +}); diff --git a/compiler/rustc_feature/src/lib.rs b/compiler/rustc_feature/src/lib.rs index f8bf0315d0c..4393368cd45 100644 --- a/compiler/rustc_feature/src/lib.rs +++ b/compiler/rustc_feature/src/lib.rs @@ -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; |
