Skip to content

Commit 49843b2

Browse files
author
Lukas Markeffsky
committed
proc_macro bridge: remove fxhash
1 parent 1d35638 commit 49843b2

File tree

4 files changed

+9
-121
lines changed

4 files changed

+9
-121
lines changed

library/proc_macro/src/bridge/fxhash.rs

-113
This file was deleted.

library/proc_macro/src/bridge/handle.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::num::NonZero;
66
use std::ops::{Index, IndexMut};
77
use std::sync::atomic::{AtomicU32, Ordering};
88

9-
use super::fxhash::FxHashMap;
9+
use super::DeterministicHashMap;
1010

1111
pub(super) type Handle = NonZero<u32>;
1212

@@ -56,12 +56,12 @@ impl<T> IndexMut<Handle> for OwnedStore<T> {
5656
/// Like `OwnedStore`, but avoids storing any value more than once.
5757
pub(super) struct InternedStore<T: 'static> {
5858
owned: OwnedStore<T>,
59-
interner: FxHashMap<T, Handle>,
59+
interner: DeterministicHashMap<T, Handle>,
6060
}
6161

6262
impl<T: Copy + Eq + Hash> InternedStore<T> {
6363
pub(super) fn new(counter: &'static AtomicU32) -> Self {
64-
InternedStore { owned: OwnedStore::new(counter), interner: FxHashMap::default() }
64+
InternedStore { owned: OwnedStore::new(counter), interner: DeterministicHashMap::default() }
6565
}
6666

6767
pub(super) fn alloc(&mut self, x: T) -> Handle {

library/proc_macro/src/bridge/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
99
#![deny(unsafe_code)]
1010

11-
use std::hash::Hash;
11+
use std::collections::HashMap;
12+
use std::hash::{BuildHasherDefault, DefaultHasher, Hash};
1213
use std::ops::{Bound, Range};
1314
use std::sync::Once;
1415
use std::{fmt, marker, mem, panic, thread};
1516

1617
use crate::{Delimiter, Level, Spacing};
1718

19+
type DeterministicHashMap<K, V> = HashMap<K, V, BuildHasherDefault<DefaultHasher>>;
20+
1821
/// Higher-order macro describing the server RPC API, allowing automatic
1922
/// generation of type-safe Rust APIs, both client-side and server-side.
2023
///
@@ -155,8 +158,6 @@ pub mod client;
155158
#[allow(unsafe_code)]
156159
mod closure;
157160
#[forbid(unsafe_code)]
158-
mod fxhash;
159-
#[forbid(unsafe_code)]
160161
mod handle;
161162
#[macro_use]
162163
#[forbid(unsafe_code)]

library/proc_macro/src/bridge/symbol.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<S> DecodeMut<'_, '_, S> for Symbol {
128128
thread_local! {
129129
static INTERNER: RefCell<Interner> = RefCell::new(Interner {
130130
arena: arena::Arena::new(),
131-
names: fxhash::FxHashMap::default(),
131+
names: DeterministicHashMap::default(),
132132
strings: Vec::new(),
133133
// Start with a base of 1 to make sure that `NonZero<u32>` works.
134134
sym_base: NonZero::new(1).unwrap(),
@@ -141,7 +141,7 @@ struct Interner {
141141
// SAFETY: These `'static` lifetimes are actually references to data owned
142142
// by the Arena. This is safe, as we never return them as static references
143143
// from `Interner`.
144-
names: fxhash::FxHashMap<&'static str, Symbol>,
144+
names: DeterministicHashMap<&'static str, Symbol>,
145145
strings: Vec<&'static str>,
146146
// The offset to apply to symbol names stored in the interner. This is used
147147
// to ensure that symbol names are not re-used after the interner is

0 commit comments

Comments
 (0)