diff --git a/Cargo.lock b/Cargo.lock index 3cc5aec6cacc..f4a8855b4c56 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 3f8047e931e9..7a06bce13c80 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 879f06f89a70..5d1b1bde84a1 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 = { - 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> = 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 f8bf0315d0c9..4393368cd452 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;