Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal: Less once_cell more std #15542

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ lint = "clippy --all-targets -- -Aclippy::collapsible_if -Aclippy::needless_pass
linker = "rust-lld"

[env]
CARGO_WORKSPACE_DIR = { value = "", relative = true }
CARGO_WORKSPACE_DIR = { value = "", relative = true }
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions crates/hir-def/src/attr/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
//! name resolution, and `BUILTIN_ATTRIBUTES` is almost entirely unchanged from the original, to
//! ease updating.

use once_cell::sync::OnceCell;
use std::sync::OnceLock;

use rustc_hash::FxHashMap;

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

pub fn find_builtin_attr_idx(name: &str) -> Option<usize> {
static BUILTIN_LOOKUP_TABLE: OnceCell<FxHashMap<&'static str, usize>> = OnceCell::new();
static BUILTIN_LOOKUP_TABLE: OnceLock<FxHashMap<&'static str, usize>> = OnceLock::new();
BUILTIN_LOOKUP_TABLE
.get_or_init(|| {
INERT_ATTRIBUTES.iter().map(|attr| attr.name).enumerate().map(|(a, b)| (b, a)).collect()
Expand Down
3 changes: 2 additions & 1 deletion crates/hir-def/src/lower.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//! Context for lowering paths.
use std::cell::OnceCell;

use hir_expand::{
ast_id_map::{AstIdMap, AstIdNode},
hygiene::Hygiene,
AstId, HirFileId, InFile,
};
use once_cell::unsync::OnceCell;
use syntax::ast;
use triomphe::Arc;

Expand Down
11 changes: 5 additions & 6 deletions crates/ide/src/typing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,16 @@ fn on_char_typed_inner(
if !stdx::always!(TRIGGER_CHARS.contains(char_typed)) {
return None;
}
return match char_typed {
let conv = |text_edit: Option<TextEdit>| {
Some(ExtendedTextEdit { edit: text_edit?, is_snippet: false })
};
match char_typed {
'.' => conv(on_dot_typed(&file.tree(), offset)),
'=' => conv(on_eq_typed(&file.tree(), offset)),
'<' => on_left_angle_typed(&file.tree(), offset),
'>' => conv(on_right_angle_typed(&file.tree(), offset)),
'{' => conv(on_opening_brace_typed(file, offset)),
_ => return None,
};

fn conv(text_edit: Option<TextEdit>) -> Option<ExtendedTextEdit> {
Some(ExtendedTextEdit { edit: text_edit?, is_snippet: false })
_ => None,
}
}

Expand Down
1 change: 0 additions & 1 deletion crates/intern/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ doctest = false
# We need to freeze the version of the crate, as the raw-api feature is considered unstable
dashmap = { version = "=5.4.0", features = ["raw-api"] }
hashbrown.workspace = true
once_cell = "1.17.0"
rustc-hash = "1.1.0"
triomphe.workspace = true
6 changes: 3 additions & 3 deletions crates/intern/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use std::{
fmt::{self, Debug, Display},
hash::{BuildHasherDefault, Hash, Hasher},
ops::Deref,
sync::OnceLock,
};

use dashmap::{DashMap, SharedValue};
use hashbrown::{hash_map::RawEntryMut, HashMap};
use once_cell::sync::OnceCell;
use rustc_hash::FxHasher;
use triomphe::Arc;

Expand Down Expand Up @@ -177,12 +177,12 @@ impl<T: Display + Internable + ?Sized> Display for Interned<T> {
}

pub struct InternStorage<T: ?Sized> {
map: OnceCell<InternMap<T>>,
map: OnceLock<InternMap<T>>,
}

impl<T: ?Sized> InternStorage<T> {
pub const fn new() -> Self {
Self { map: OnceCell::new() }
Self { map: OnceLock::new() }
}
}

Expand Down