Skip to content

Commit 73a7204

Browse files
committed
feature: replace lazy_static by SyncLazy from std
1 parent 67b8f94 commit 73a7204

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -3513,7 +3513,6 @@ dependencies = [
35133513
name = "rustc_feature"
35143514
version = "0.0.0"
35153515
dependencies = [
3516-
"lazy_static",
35173516
"rustc_data_structures",
35183517
"rustc_span",
35193518
]

compiler/rustc_feature/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ doctest = false
99

1010
[dependencies]
1111
rustc_data_structures = { path = "../rustc_data_structures" }
12-
lazy_static = "1.0.0"
1312
rustc_span = { path = "../rustc_span" }

compiler/rustc_feature/src/builtin_attrs.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ use AttributeType::*;
55

66
use crate::{Features, Stability};
77

8-
use lazy_static::lazy_static;
98
use rustc_data_structures::fx::FxHashMap;
109
use rustc_span::symbol::{sym, Symbol};
1110

11+
use std::lazy::SyncLazy;
12+
1213
type GateFn = fn(&Features) -> bool;
1314

1415
macro_rules! cfg_fn {
@@ -589,14 +590,12 @@ pub fn is_builtin_attr_name(name: Symbol) -> bool {
589590
BUILTIN_ATTRIBUTE_MAP.get(&name).is_some()
590591
}
591592

592-
lazy_static! {
593-
pub static ref BUILTIN_ATTRIBUTE_MAP: FxHashMap<Symbol, &'static BuiltinAttribute> = {
594-
let mut map = FxHashMap::default();
595-
for attr in BUILTIN_ATTRIBUTES.iter() {
596-
if map.insert(attr.0, attr).is_some() {
597-
panic!("duplicate builtin attribute `{}`", attr.0);
598-
}
593+
pub static BUILTIN_ATTRIBUTE_MAP: SyncLazy<FxHashMap<Symbol, &'static BuiltinAttribute>> = SyncLazy::new(|| {
594+
let mut map = FxHashMap::default();
595+
for attr in BUILTIN_ATTRIBUTES.iter() {
596+
if map.insert(attr.0, attr).is_some() {
597+
panic!("duplicate builtin attribute `{}`", attr.0);
599598
}
600-
map
601-
};
602-
}
599+
}
600+
map
601+
});

compiler/rustc_feature/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
//! even if it is stabilized or removed, *do not remove it*. Instead, move the
1212
//! symbol to the `accepted` or `removed` modules respectively.
1313
14+
#![feature(once_cell)]
15+
1416
mod accepted;
1517
mod active;
1618
mod builtin_attrs;

0 commit comments

Comments
 (0)