Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/intern/src/symbol/symbols.rs')
-rw-r--r--crates/intern/src/symbol/symbols.rs77
1 files changed, 31 insertions, 46 deletions
diff --git a/crates/intern/src/symbol/symbols.rs b/crates/intern/src/symbol/symbols.rs
index 6b77c72cee..abde48d151 100644
--- a/crates/intern/src/symbol/symbols.rs
+++ b/crates/intern/src/symbol/symbols.rs
@@ -1,72 +1,47 @@
//! Module defining all known symbols required by the rest of rust-analyzer.
#![allow(non_upper_case_globals)]
-use std::hash::{BuildHasherDefault, Hash as _, Hasher as _};
+use std::hash::{BuildHasher, BuildHasherDefault};
use dashmap::{DashMap, SharedValue};
use rustc_hash::FxHasher;
-use crate::{
- symbol::{SymbolProxy, TaggedArcPtr},
- Symbol,
-};
+use crate::{Symbol, symbol::TaggedArcPtr};
macro_rules! define_symbols {
(@WITH_NAME: $($alias:ident = $value:literal,)* @PLAIN: $($name:ident,)*) => {
- // We define symbols as both `const`s and `static`s because some const code requires const symbols,
- // but code from before the transition relies on the lifetime of the predefined symbols and making them
- // `const`s make it error (because now they're temporaries). In the future we probably should only
- // use consts.
-
- /// Predefined symbols as `const`s (instead of the default `static`s).
- pub mod consts {
- use super::{Symbol, TaggedArcPtr};
-
- // The strings should be in `static`s so that symbol equality holds.
- $(
- pub const $name: Symbol = {
- static SYMBOL_STR: &str = stringify!($name);
- Symbol { repr: TaggedArcPtr::non_arc(&SYMBOL_STR) }
- };
- )*
- $(
- pub const $alias: Symbol = {
- static SYMBOL_STR: &str = $value;
- Symbol { repr: TaggedArcPtr::non_arc(&SYMBOL_STR) }
- };
- )*
- }
-
+ // The strings should be in `static`s so that symbol equality holds.
$(
- pub static $name: Symbol = consts::$name;
+ pub const $name: Symbol = {
+ static SYMBOL_STR: &str = stringify!($name);
+ Symbol { repr: TaggedArcPtr::non_arc(&SYMBOL_STR) }
+ };
)*
$(
- pub static $alias: Symbol = consts::$alias;
+ pub const $alias: Symbol = {
+ static SYMBOL_STR: &str = $value;
+ Symbol { repr: TaggedArcPtr::non_arc(&SYMBOL_STR) }
+ };
)*
- pub(super) fn prefill() -> DashMap<SymbolProxy, (), BuildHasherDefault<FxHasher>> {
- let mut dashmap_ = <DashMap<SymbolProxy, (), BuildHasherDefault<FxHasher>>>::with_hasher(BuildHasherDefault::default());
+ pub(super) fn prefill() -> DashMap<Symbol, (), BuildHasherDefault<FxHasher>> {
+ let mut dashmap_ = <DashMap<Symbol, (), BuildHasherDefault<FxHasher>>>::with_hasher(BuildHasherDefault::default());
- let hash_thing_ = |hasher_: &BuildHasherDefault<FxHasher>, it_: &SymbolProxy| {
- let mut hasher_ = std::hash::BuildHasher::build_hasher(hasher_);
- it_.hash(&mut hasher_);
- hasher_.finish()
- };
+ let hasher_ = dashmap_.hasher().clone();
+ let hash_one = |it_: &str| hasher_.hash_one(it_);
{
$(
-
- let proxy_ = SymbolProxy($name.repr);
- let hash_ = hash_thing_(dashmap_.hasher(), &proxy_);
+ let s = stringify!($name);
+ let hash_ = hash_one(s);
let shard_idx_ = dashmap_.determine_shard(hash_ as usize);
- dashmap_.shards_mut()[shard_idx_].get_mut().raw_entry_mut().from_hash(hash_, |k| k == &proxy_).insert(proxy_, SharedValue::new(()));
+ dashmap_.shards_mut()[shard_idx_].get_mut().insert(hash_, ($name, SharedValue::new(())), |(x, _)| hash_one(x.as_str()));
)*
$(
-
- let proxy_ = SymbolProxy($alias.repr);
- let hash_ = hash_thing_(dashmap_.hasher(), &proxy_);
+ let s = $value;
+ let hash_ = hash_one(s);
let shard_idx_ = dashmap_.determine_shard(hash_ as usize);
- dashmap_.shards_mut()[shard_idx_].get_mut().raw_entry_mut().from_hash(hash_, |k| k == &proxy_).insert(proxy_, SharedValue::new(()));
+ dashmap_.shards_mut()[shard_idx_].get_mut().insert(hash_, ($alias, SharedValue::new(())), |(x, _)| hash_one(x.as_str()));
)*
}
dashmap_
@@ -161,6 +136,7 @@ define_symbols! {
bitxor_assign,
bitxor,
bool,
+ bootstrap,
box_free,
Box,
boxed,
@@ -511,6 +487,7 @@ define_symbols! {
unreachable_2021,
unreachable,
unsafe_cell,
+ unsafe_pinned,
unsize,
unstable,
usize,
@@ -521,4 +498,12 @@ define_symbols! {
win64,
array,
boxed_slice,
+ completions,
+ ignore_flyimport,
+ ignore_flyimport_methods,
+ ignore_methods,
+ position,
+ flags,
+ precision,
+ width,
}