Skip to content

Commit 04e6afe

Browse files
committed
Re-export hashbrown::hash_table from rustc_data_structures
1 parent 44e34e1 commit 04e6afe

File tree

7 files changed

+9
-14
lines changed

7 files changed

+9
-14
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4354,7 +4354,6 @@ name = "rustc_mir_transform"
43544354
version = "0.0.0"
43554355
dependencies = [
43564356
"either",
4357-
"hashbrown 0.16.1",
43584357
"itertools",
43594358
"rustc_abi",
43604359
"rustc_arena",
@@ -4565,7 +4564,6 @@ dependencies = [
45654564
name = "rustc_query_system"
45664565
version = "0.0.0"
45674566
dependencies = [
4568-
"hashbrown 0.16.1",
45694567
"parking_lot",
45704568
"rustc_abi",
45714569
"rustc_ast",

compiler/rustc_data_structures/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ pub use std::{assert_matches, debug_assert_matches};
4949

5050
pub use atomic_ref::AtomicRef;
5151
pub use ena::{snapshot_vec, undo_log, unify};
52+
// Re-export `hashbrown::hash_table`, because it's part of our API
53+
// (via `ShardedHashMap`), and because it lets other compiler crates use the
54+
// lower-level `HashTable` API without a tricky `hashbrown` dependency.
55+
pub use hashbrown::hash_table;
5256
pub use rustc_index::static_assert_size;
5357
// Re-export some data-structure crates which are part of our public API.
5458
pub use {either, indexmap, smallvec, thin_vec};

compiler/rustc_data_structures/src/sharded.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::hash::{Hash, Hasher};
33
use std::{iter, mem};
44

55
use either::Either;
6-
use hashbrown::hash_table::{Entry, HashTable};
6+
use hashbrown::hash_table::{self, Entry, HashTable};
77

88
use crate::fx::FxHasher;
99
use crate::sync::{CacheAligned, Lock, LockGuard, Mode, is_dyn_thread_safe};
@@ -140,7 +140,7 @@ pub fn shards() -> usize {
140140
1
141141
}
142142

143-
pub type ShardedHashMap<K, V> = Sharded<HashTable<(K, V)>>;
143+
pub type ShardedHashMap<K, V> = Sharded<hash_table::HashTable<(K, V)>>;
144144

145145
impl<K: Eq, V> ShardedHashMap<K, V> {
146146
pub fn with_capacity(cap: usize) -> Self {

compiler/rustc_mir_transform/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88
either = "1"
9-
hashbrown = { version = "0.16.1", default-features = false }
109
itertools = "0.12"
1110
rustc_abi = { path = "../rustc_abi" }
1211
rustc_arena = { path = "../rustc_arena" }

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ use std::borrow::Cow;
8888
use std::hash::{Hash, Hasher};
8989

9090
use either::Either;
91-
use hashbrown::hash_table::{Entry, HashTable};
9291
use itertools::Itertools as _;
9392
use rustc_abi::{self as abi, BackendRepr, FIRST_VARIANT, FieldIdx, Primitive, Size, VariantIdx};
9493
use rustc_arena::DroplessArena;
@@ -99,6 +98,7 @@ use rustc_const_eval::interpret::{
9998
};
10099
use rustc_data_structures::fx::FxHasher;
101100
use rustc_data_structures::graph::dominators::Dominators;
101+
use rustc_data_structures::hash_table::{Entry, HashTable};
102102
use rustc_hir::def::DefKind;
103103
use rustc_index::bit_set::DenseBitSet;
104104
use rustc_index::{IndexVec, newtype_index};

compiler/rustc_query_system/Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,3 @@ rustc_thread_pool = { path = "../rustc_thread_pool" }
2323
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
2424
tracing = "0.1"
2525
# tidy-alphabetical-end
26-
27-
[dependencies.hashbrown]
28-
version = "0.16.1"
29-
default-features = false
30-
features = ["nightly"] # for may_dangle

compiler/rustc_query_system/src/query/plumbing.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ use std::fmt::Debug;
77
use std::hash::Hash;
88
use std::mem;
99

10-
use hashbrown::HashTable;
11-
use hashbrown::hash_table::Entry;
1210
use rustc_data_structures::fingerprint::Fingerprint;
11+
use rustc_data_structures::hash_table::{self, Entry, HashTable};
1312
use rustc_data_structures::sharded::{self, Sharded};
1413
use rustc_data_structures::stack::ensure_sufficient_stack;
1514
use rustc_data_structures::sync::LockGuard;
@@ -35,7 +34,7 @@ fn equivalent_key<K: Eq, V>(k: &K) -> impl Fn(&(K, V)) -> bool + '_ {
3534
}
3635

3736
pub struct QueryState<'tcx, K> {
38-
active: Sharded<hashbrown::HashTable<(K, QueryResult<'tcx>)>>,
37+
active: Sharded<hash_table::HashTable<(K, QueryResult<'tcx>)>>,
3938
}
4039

4140
/// Indicates the state of a query for a given key in a query map.

0 commit comments

Comments
 (0)