Skip to content

Commit 188c1cc

Browse files
committed
Allow the lint for somewhere which seems that ordering affects nothing
1 parent 01e27a3 commit 188c1cc

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

compiler/rustc_data_structures/src/sharded.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use std::borrow::Borrow;
2+
use std::collections::hash_map::RawEntryMut;
23
use std::hash::{Hash, Hasher};
34
use std::{iter, mem};
45

56
#[cfg(parallel_compiler)]
67
use either::Either;
7-
use indexmap::map::RawEntryApiV1;
8-
use indexmap::map::raw_entry_v1::RawEntryMut;
98

10-
use crate::fx::{FxHasher, FxIndexMap};
9+
use crate::fx::{FxHashMap, FxHasher};
1110
#[cfg(parallel_compiler)]
1211
use crate::sync::{CacheAligned, is_dyn_thread_safe};
1312
use crate::sync::{Lock, LockGuard, Mode};
@@ -160,15 +159,15 @@ pub fn shards() -> usize {
160159
1
161160
}
162161

163-
pub type ShardedIndexMap<K, V> = Sharded<FxIndexMap<K, V>>;
162+
pub type ShardedHashMap<K, V> = Sharded<FxHashMap<K, V>>;
164163

165-
impl<K: Eq, V> ShardedIndexMap<K, V> {
164+
impl<K: Eq, V> ShardedHashMap<K, V> {
166165
pub fn len(&self) -> usize {
167166
self.lock_shards().map(|shard| shard.len()).sum()
168167
}
169168
}
170169

171-
impl<K: Eq + Hash + Copy> ShardedIndexMap<K, ()> {
170+
impl<K: Eq + Hash + Copy> ShardedHashMap<K, ()> {
172171
#[inline]
173172
pub fn intern_ref<Q: ?Sized>(&self, value: &Q, make: impl FnOnce() -> K) -> K
174173
where
@@ -177,7 +176,7 @@ impl<K: Eq + Hash + Copy> ShardedIndexMap<K, ()> {
177176
{
178177
let hash = make_hash(value);
179178
let mut shard = self.lock_shard_by_hash(hash);
180-
let entry = shard.raw_entry_mut_v1().from_key_hashed_nocheck(hash, value);
179+
let entry = shard.raw_entry_mut().from_key_hashed_nocheck(hash, value);
181180

182181
match entry {
183182
RawEntryMut::Occupied(e) => *e.key(),
@@ -197,7 +196,7 @@ impl<K: Eq + Hash + Copy> ShardedIndexMap<K, ()> {
197196
{
198197
let hash = make_hash(&value);
199198
let mut shard = self.lock_shard_by_hash(hash);
200-
let entry = shard.raw_entry_mut_v1().from_key_hashed_nocheck(hash, &value);
199+
let entry = shard.raw_entry_mut().from_key_hashed_nocheck(hash, &value);
201200

202201
match entry {
203202
RawEntryMut::Occupied(e) => *e.key(),
@@ -215,12 +214,12 @@ pub trait IntoPointer {
215214
fn into_pointer(&self) -> *const ();
216215
}
217216

218-
impl<K: Eq + Hash + Copy + IntoPointer> ShardedIndexMap<K, ()> {
217+
impl<K: Eq + Hash + Copy + IntoPointer> ShardedHashMap<K, ()> {
219218
pub fn contains_pointer_to<T: Hash + IntoPointer>(&self, value: &T) -> bool {
220219
let hash = make_hash(&value);
221220
let shard = self.lock_shard_by_hash(hash);
222221
let value = value.into_pointer();
223-
shard.raw_entry_v1().from_hash(hash, |entry| entry.into_pointer() == value).is_some()
222+
shard.raw_entry().from_hash(hash, |entry| entry.into_pointer() == value).is_some()
224223
}
225224
}
226225

compiler/rustc_middle/src/ty/context.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_data_structures::fingerprint::Fingerprint;
1919
use rustc_data_structures::fx::FxHashMap;
2020
use rustc_data_structures::intern::Interned;
2121
use rustc_data_structures::profiling::SelfProfilerRef;
22-
use rustc_data_structures::sharded::{IntoPointer, ShardedIndexMap};
22+
use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
2323
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2424
use rustc_data_structures::steal::Steal;
2525
use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, Lrc, RwLock, WorkerLocal};
@@ -742,7 +742,7 @@ impl<'tcx> rustc_type_ir::inherent::Span<TyCtxt<'tcx>> for Span {
742742
}
743743
}
744744

745-
type InternedSet<'tcx, T> = ShardedIndexMap<InternedInSet<'tcx, T>, ()>;
745+
type InternedSet<'tcx, T> = ShardedHashMap<InternedInSet<'tcx, T>, ()>;
746746

747747
pub struct CtxtInterners<'tcx> {
748748
/// The arena that types, regions, etc. are allocated from.
@@ -2242,6 +2242,8 @@ macro_rules! sty_debug_print {
22422242
$(let mut $variant = total;)*
22432243

22442244
for shard in tcx.interners.type_.lock_shards() {
2245+
// It seems that ordering doesn't affect anything here.
2246+
#[allow(rustc::potential_query_instability)]
22452247
let types = shard.keys();
22462248
for &InternedInSet(t) in types {
22472249
let variant = match t.internee {

0 commit comments

Comments
 (0)