Skip to content

Commit ce650ce

Browse files
committed
Auto merge of rust-lang#15542 - Veykril:std-once, r=Veykril
Less `once_cell` more `std`
2 parents 3213344 + c09f175 commit ce650ce

File tree

7 files changed

+14
-15
lines changed

7 files changed

+14
-15
lines changed

.cargo/config.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ lint = "clippy --all-targets -- -Aclippy::collapsible_if -Aclippy::needless_pass
88
linker = "rust-lld"
99

1010
[env]
11-
CARGO_WORKSPACE_DIR = { value = "", relative = true }
11+
CARGO_WORKSPACE_DIR = { value = "", relative = true }

Cargo.lock

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/hir-def/src/attr/builtin.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
//! name resolution, and `BUILTIN_ATTRIBUTES` is almost entirely unchanged from the original, to
99
//! ease updating.
1010
11-
use once_cell::sync::OnceCell;
11+
use std::sync::OnceLock;
12+
1213
use rustc_hash::FxHashMap;
1314

1415
/// Ignored attribute namespaces used by tools.
@@ -29,7 +30,7 @@ pub struct AttributeTemplate {
2930
}
3031

3132
pub fn find_builtin_attr_idx(name: &str) -> Option<usize> {
32-
static BUILTIN_LOOKUP_TABLE: OnceCell<FxHashMap<&'static str, usize>> = OnceCell::new();
33+
static BUILTIN_LOOKUP_TABLE: OnceLock<FxHashMap<&'static str, usize>> = OnceLock::new();
3334
BUILTIN_LOOKUP_TABLE
3435
.get_or_init(|| {
3536
INERT_ATTRIBUTES.iter().map(|attr| attr.name).enumerate().map(|(a, b)| (b, a)).collect()

crates/hir-def/src/lower.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//! Context for lowering paths.
2+
use std::cell::OnceCell;
3+
24
use hir_expand::{
35
ast_id_map::{AstIdMap, AstIdNode},
46
hygiene::Hygiene,
57
AstId, HirFileId, InFile,
68
};
7-
use once_cell::unsync::OnceCell;
89
use syntax::ast;
910
use triomphe::Arc;
1011

crates/ide/src/typing.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,16 @@ fn on_char_typed_inner(
8686
if !stdx::always!(TRIGGER_CHARS.contains(char_typed)) {
8787
return None;
8888
}
89-
return match char_typed {
89+
let conv = |text_edit: Option<TextEdit>| {
90+
Some(ExtendedTextEdit { edit: text_edit?, is_snippet: false })
91+
};
92+
match char_typed {
9093
'.' => conv(on_dot_typed(&file.tree(), offset)),
9194
'=' => conv(on_eq_typed(&file.tree(), offset)),
9295
'<' => on_left_angle_typed(&file.tree(), offset),
9396
'>' => conv(on_right_angle_typed(&file.tree(), offset)),
9497
'{' => conv(on_opening_brace_typed(file, offset)),
95-
_ => return None,
96-
};
97-
98-
fn conv(text_edit: Option<TextEdit>) -> Option<ExtendedTextEdit> {
99-
Some(ExtendedTextEdit { edit: text_edit?, is_snippet: false })
98+
_ => None,
10099
}
101100
}
102101

crates/intern/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ doctest = false
1616
# We need to freeze the version of the crate, as the raw-api feature is considered unstable
1717
dashmap = { version = "=5.4.0", features = ["raw-api"] }
1818
hashbrown.workspace = true
19-
once_cell = "1.17.0"
2019
rustc-hash = "1.1.0"
2120
triomphe.workspace = true

crates/intern/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ use std::{
66
fmt::{self, Debug, Display},
77
hash::{BuildHasherDefault, Hash, Hasher},
88
ops::Deref,
9+
sync::OnceLock,
910
};
1011

1112
use dashmap::{DashMap, SharedValue};
1213
use hashbrown::{hash_map::RawEntryMut, HashMap};
13-
use once_cell::sync::OnceCell;
1414
use rustc_hash::FxHasher;
1515
use triomphe::Arc;
1616

@@ -177,12 +177,12 @@ impl<T: Display + Internable + ?Sized> Display for Interned<T> {
177177
}
178178

179179
pub struct InternStorage<T: ?Sized> {
180-
map: OnceCell<InternMap<T>>,
180+
map: OnceLock<InternMap<T>>,
181181
}
182182

183183
impl<T: ?Sized> InternStorage<T> {
184184
pub const fn new() -> Self {
185-
Self { map: OnceCell::new() }
185+
Self { map: OnceLock::new() }
186186
}
187187
}
188188

0 commit comments

Comments
 (0)