Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1033caf0b349c518623b5396bfb2cf0bddf44f0306d543a250e5743297aafd10"
dependencies = [
"fnv",
"hashbrown",
"hashbrown 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap",
"stable_deref_trait",
]
Expand Down Expand Up @@ -1688,6 +1688,14 @@ dependencies = [
"serde_core",
]

[[package]]
name = "hashbrown"
version = "0.17.1"
source = "git+https://github.com/Zoxc/hashbrown.git?branch=linear-probes#dc5066465f34332634fadf2abb0da9d095da2348"
dependencies = [
"foldhash 0.2.0",
]

[[package]]
name = "heck"
version = "0.5.0"
Expand Down Expand Up @@ -1977,7 +1985,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
dependencies = [
"equivalent",
"hashbrown",
"hashbrown 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde",
"serde_core",
]
Expand Down Expand Up @@ -2783,7 +2791,7 @@ checksum = "2e5a6c098c7a3b6547378093f5cc30bc54fd361ce711e05293a5cc589562739b"
dependencies = [
"crc32fast",
"flate2",
"hashbrown",
"hashbrown 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap",
"memchr",
"ruzstd",
Expand Down Expand Up @@ -3456,7 +3464,7 @@ checksum = "d9776093b7ca170454ab1406954f7b7d97a57c51dc6c0642957fb2ef25c2d399"
dependencies = [
"bytecheck",
"bytes",
"hashbrown",
"hashbrown 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap",
"munge",
"ptr_meta",
Expand Down Expand Up @@ -3915,7 +3923,7 @@ dependencies = [
"either",
"elsa",
"ena",
"hashbrown",
"hashbrown 0.17.1 (git+https://github.com/Zoxc/hashbrown.git?branch=linear-probes)",
"indexmap",
"jobserver",
"libc",
Expand Down Expand Up @@ -4760,6 +4768,7 @@ dependencies = [
name = "rustc_serialize"
version = "0.0.0"
dependencies = [
"hashbrown 0.17.1 (git+https://github.com/Zoxc/hashbrown.git?branch=linear-probes)",
"indexmap",
"rustc_hashes",
"rustc_macros",
Expand Down Expand Up @@ -4983,6 +4992,7 @@ dependencies = [
"bitflags",
"derive-where",
"ena",
"hashbrown 0.17.1 (git+https://github.com/Zoxc/hashbrown.git?branch=linear-probes)",
"indexmap",
"rustc-hash 2.1.1",
"rustc_abi",
Expand Down Expand Up @@ -5718,7 +5728,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5938a79ecf9cb8198d525ddb37cd8841f66ab98073f6a123af7ed7cdcbb73ae"
dependencies = [
"gimli 0.34.0",
"hashbrown",
"hashbrown 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools",
"object 0.39.1",
"tracing",
Expand Down Expand Up @@ -6464,7 +6474,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d92fc335fb6d48f46bda1d8b26b69e28320c15ac3272208333833d6e217e2b4a"
dependencies = [
"bitflags",
"hashbrown",
"hashbrown 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap",
"semver",
"serde",
Expand Down Expand Up @@ -6883,7 +6893,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f815340f0bb65d9775ae21e56b503b496683557b9b627b195d2766c25fb24ae"
dependencies = [
"anyhow",
"hashbrown",
"hashbrown 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"id-arena",
"indexmap",
"log",
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::hash_map::Entry;

use rustc_ast::*;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_data_structures::hash_map::Entry;
use rustc_errors::msg;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
Expand Down Expand Up @@ -452,7 +451,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
overlapping_with.push(reg);
});
let output_used =
overlapping_with.iter().any(|reg| used_output_regs.contains_key(&reg));
overlapping_with.iter().any(|reg| used_output_regs.contains_key(reg));

if !output_used {
operands.push((
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/borrow_set.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::hash_map::Entry;
use std::fmt;
use std::ops::Index;

use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
use rustc_data_structures::hash_map::Entry;
use rustc_hir::Mutability;
use rustc_index::IndexVec;
use rustc_index::bit_set::DenseBitSet;
Expand Down Expand Up @@ -102,7 +102,7 @@ impl<'tcx> BorrowSet<'tcx> {

// Public method to support Creusot.
pub fn activations_at_location(&self, location: &Location) -> &[BorrowIndex] {
self.activation_map.get(&location).map_or(&[], |activations| &activations[..])
self.activation_map.get(location).map_or(&[], |activations| &activations[..])
}

// Public method to support Creusot.
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_cranelift/src/pretty_clif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl CommentWriter {
) {
debug_assert!(self.enabled);

use std::collections::hash_map::Entry;
use rustc_data_structures::hash_map::Entry;
match self.entity_comments.entry(entity.into()) {
Entry::Occupied(mut occ) => {
occ.get_mut().push('\n');
Expand All @@ -143,7 +143,7 @@ impl CommentWriter {
) {
debug_assert!(self.enabled);

use std::collections::hash_map::Entry;
use rustc_data_structures::hash_map::Entry;
match self.inst_post_comments.entry(entity) {
Entry::Occupied(mut occ) => {
occ.get_mut().push('\n');
Expand Down Expand Up @@ -210,7 +210,7 @@ impl FuncWriter for &'_ CommentWriter {
inst: Inst,
indent: usize,
) -> fmt::Result {
if let Some(comment) = self.entity_comments.get(&inst.into()) {
if let Some(comment) = self.entity_comments.get::<AnyEntity>(&inst.into()) {
writeln!(w, "; {}", comment.replace('\n', "\n; "))?;
}
PlainWriter.write_instruction(w, func, aliases, inst, indent)?;
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_ssa/src/back/symbol_export.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::collections::hash_map::Entry::*;

use rustc_abi::{CanonAbi, X86Call};
use rustc_ast::expand::allocator::{AllocatorKind, NO_ALLOC_SHIM_IS_UNSTABLE, global_fn_name};
use rustc_crate_store::CrateDepKind;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::hash_map::Entry::*;
use rustc_data_structures::unord::UnordMap;
use rustc_hir as hir;
use rustc_hir::def::DefKind;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/mir/debuginfo.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::collections::hash_map::Entry;
use std::marker::PhantomData;
use std::ops::Range;

use rustc_abi::{BackendRepr, FieldIdx, FieldsShape, Size, VariantIdx};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::hash_map::Entry;
use rustc_index::IndexVec;
use rustc_index::bit_set::DenseBitSet;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ pub(crate) fn provide(providers: &mut Providers) {
// hope that this doesn't cause issues anywhere else in the compiler...
let mut result: UnordMap<String, Stability> = Default::default();
for (name, stability) in rustc_target::target_features::all_rust_features() {
use std::collections::hash_map::Entry;
use rustc_data_structures::hash_map::Entry;
match result.entry(name.to_owned()) {
Entry::Vacant(vacant_entry) => {
vacant_entry.insert(stability);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/eval_context.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::cell::RefCell;
use std::collections::hash_map::Entry;

use either::{Left, Right};
use rustc_abi::{Align, HasDataLayout, Size, TargetDataLayout};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::hash_map::Entry;
use rustc_hir::def_id::DefId;
use rustc_middle::mir::interpret::{ErrorHandled, InvalidMetaKind, ReportedErrorInfo};
use rustc_middle::query::TyCtxtAt;
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ tracing = "0.1"
# tidy-alphabetical-end

[dependencies.hashbrown]
version = "0.17.0"
git = "https://github.com/Zoxc/hashbrown.git"
branch = "linear-probes"
default-features = false
features = ["nightly"] # for may_dangle

Expand Down
14 changes: 11 additions & 3 deletions compiler/rustc_data_structures/src/fx.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
pub use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet, FxHasher};
pub use rustc_hash::{FxBuildHasher, FxHasher};

pub type StdEntry<'a, K, V> = std::collections::hash_map::Entry<'a, K, V>;
// These are `hashbrown`'s hash map and set rather than the standard library's, even though the
// standard library's are themselves a thin wrapper around `hashbrown`. Depending on `hashbrown`
// directly means the compiler uses the version this workspace resolves, rather than whichever copy
// happens to be baked into the standard library it is compiled against. [LLM-generated]
pub type FxHashMap<K, V> = hashbrown::HashMap<K, V, FxBuildHasher>;
pub type FxHashSet<V> = hashbrown::HashSet<V, FxBuildHasher>;

pub type MapEntry<'a, K, V> = hashbrown::hash_map::Entry<'a, K, V, FxBuildHasher>;
pub type MapOccupiedError<'a, K, V> = hashbrown::hash_map::OccupiedError<'a, K, V, FxBuildHasher>;

pub type FxIndexMap<K, V> = indexmap::IndexMap<K, V, FxBuildHasher>;
pub type FxIndexSet<V> = indexmap::IndexSet<V, FxBuildHasher>;
Expand All @@ -14,7 +22,7 @@ macro_rules! define_id_collections {
($map_name:ident, $set_name:ident, $entry_name:ident, $key:ty) => {
pub type $map_name<T> = $crate::unord::UnordMap<$key, T>;
pub type $set_name = $crate::unord::UnordSet<$key>;
pub type $entry_name<'a, T> = $crate::fx::StdEntry<'a, $key, T>;
pub type $entry_name<'a, T> = $crate::fx::MapEntry<'a, $key, T>;
};
}

Expand Down
9 changes: 4 additions & 5 deletions compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#![feature(dropck_eyepatch)]
#![feature(extend_one)]
#![feature(file_buffered)]
#![feature(map_try_insert)]
#![feature(min_specialization)]
#![feature(negative_impls)]
#![feature(nonzero_internals)]
Expand All @@ -44,10 +43,10 @@ use std::fmt;

pub use atomic_ref::AtomicRef;
pub use ena::{snapshot_vec, undo_log, unify};
// Re-export `hashbrown::hash_table`, because it's part of our API
// (via `ShardedHashMap`), and because it lets other compiler crates use the
// lower-level `HashTable` API without a tricky `hashbrown` dependency.
pub use hashbrown::hash_table;
// Re-export `hashbrown`'s map, set and table modules, because they are part of our API
// (via `FxHashMap`, `FxHashSet` and `ShardedHashMap`), and because it lets other compiler crates
// use the lower-level `HashTable` API without a tricky `hashbrown` dependency.
pub use hashbrown::{hash_map, hash_set, hash_table};
pub use rustc_index::static_assert_size;
// Re-export some data-structure crates which are part of our public API.
pub use {either, indexmap, smallvec, thin_vec};
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_data_structures/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ impl_dyn_send!(
[crate::tagged_ptr::TaggedRef<'a, P, T> where 'a, P: Sync, T: Send + crate::tagged_ptr::Tag]
[rustc_arena::TypedArena<T> where T: DynSend]
[hashbrown::HashTable<T> where T: DynSend]
[hashbrown::HashSet<K, S> where K: DynSend, S: DynSend]
[hashbrown::HashMap<K, V, S> where K: DynSend, V: DynSend, S: DynSend]
[indexmap::IndexSet<V, S> where V: DynSend, S: DynSend]
[indexmap::IndexMap<K, V, S> where K: DynSend, V: DynSend, S: DynSend]
[thin_vec::ThinVec<T> where T: DynSend]
Expand Down Expand Up @@ -178,6 +180,8 @@ impl_dyn_sync!(
[parking_lot::lock_api::Mutex<R, T> where R: DynSync, T: ?Sized + DynSend]
[parking_lot::lock_api::RwLock<R, T> where R: DynSync, T: ?Sized + DynSend + DynSync]
[hashbrown::HashTable<T> where T: DynSync]
[hashbrown::HashSet<K, S> where K: DynSync, S: DynSync]
[hashbrown::HashMap<K, V, S> where K: DynSync, V: DynSync, S: DynSync]
[indexmap::IndexSet<V, S> where V: DynSync, S: DynSync]
[indexmap::IndexMap<K, V, S> where K: DynSync, V: DynSync, S: DynSync]
[smallvec::SmallVec<A> where A: smallvec::Array + DynSync]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@
//! aren't needed anymore.

use std::cell::Cell;
use std::collections::hash_map::Entry;
use std::fmt::Debug;
use std::hash;
use std::marker::PhantomData;

use hashbrown::hash_map::Entry;
use thin_vec::ThinVec;
use tracing::debug;

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
//! [mm]: https://github.com/rust-lang/measureme/

use std::borrow::Borrow;
use std::collections::hash_map::Entry;
use std::error::Error;
use std::fmt::Display;
use std::path::Path;
Expand All @@ -91,6 +90,7 @@ use std::sync::atomic::Ordering;
use std::time::{Duration, Instant};
use std::{fs, hint, process};

use hashbrown::hash_map::Entry;
pub use measureme::EventId;
use measureme::{EventIdBuilder, Profiler, SerializableString, StringId};
use parking_lot::RwLock;
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_data_structures/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
//! | | | `parking_lot::Mutex<T>` |
//! | `RwLock<T>` | `parking_lot::RwLock<T>` | `parking_lot::RwLock<T>` |

use std::collections::HashMap;
use std::hash::{BuildHasher, Hash};

pub use parking_lot::{
Expand Down Expand Up @@ -163,7 +162,7 @@ pub trait HashMapExt<K, V> {
fn insert_same(&mut self, key: K, value: V);
}

impl<K: Eq + Hash, V: Eq, S: BuildHasher> HashMapExt<K, V> for HashMap<K, V, S> {
impl<K: Eq + Hash, V: Eq, S: BuildHasher> HashMapExt<K, V> for hashbrown::HashMap<K, V, S> {
fn insert_same(&mut self, key: K, value: V) {
self.entry(key).and_modify(|old| assert!(*old == value)).or_insert(value);
}
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_data_structures/src/unord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
//! as required by the query system.

use std::borrow::{Borrow, BorrowMut};
use std::collections::hash_map::{Entry, OccupiedError};
use std::hash::Hash;
use std::iter::{Product, Sum};
use std::ops::Index;

use rustc_macros::{Decodable_NoContext, Encodable_NoContext};

use crate::fingerprint::Fingerprint;
use crate::fx::{FxBuildHasher, FxHashMap, FxHashSet};
use crate::fx::{FxBuildHasher, FxHashMap, FxHashSet, MapEntry, MapOccupiedError};
use crate::stable_hash::{
StableCompare, StableHash, StableHashCtxt, StableHasher, ToStableHashKey,
};
Expand Down Expand Up @@ -501,7 +500,7 @@ impl<K: Eq + Hash, V> UnordMap<K, V> {
}

#[inline]
pub fn try_insert(&mut self, k: K, v: V) -> Result<&mut V, OccupiedError<'_, K, V>> {
pub fn try_insert(&mut self, k: K, v: V) -> Result<&mut V, MapOccupiedError<'_, K, V>> {
self.inner.try_insert(k, v)
}

Expand All @@ -520,7 +519,7 @@ impl<K: Eq + Hash, V> UnordMap<K, V> {
}

#[inline]
pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
pub fn entry(&mut self, key: K) -> MapEntry<'_, K, V> {
self.inner.entry(key)
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/mbe/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ impl<'dcx, 'matcher> Tracker<'matcher> for CollectTrackerAndEmitter<'dcx, 'match
bug!("`Self::prepare()` was not called to initialize context");
};

#[expect(
#[allow(
rustc::potential_query_instability,
reason = "sorting the results deterministically afterwards"
)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::borrow::Cow;
use std::collections::hash_map::Entry;
use std::sync::Arc;
use std::{mem, slice};

Expand All @@ -13,6 +12,7 @@ use rustc_ast_pretty::pprust;
use rustc_attr_ir::diagnostic::Directive;
use rustc_attr_ir::{self as attrs, find_attr};
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_data_structures::hash_map::Entry;
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan};
use rustc_feature::Features;
use rustc_hir::def::MacroKinds;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::hash_map::Entry;
use std::slice;

use rustc_abi::FieldIdx;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::hash_map::Entry;
use rustc_data_structures::thin_vec::ThinVec;
use rustc_errors::{
Applicability, Diag, DiagCtxtHandle, Diagnostic, ErrorGuaranteed, Level, MultiSpan,
Expand Down
Loading
Loading