Skip to content

Commit f992e65

Browse files
committed
Some work
1 parent 91d75ea commit f992e65

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

compiler/rustc_middle/src/ty/mod.rs

+14-22
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use crate::ty::util::Discr;
2929
use rustc_ast as ast;
3030
use rustc_attr as attr;
3131
use rustc_data_structures::intern::Interned;
32-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
32+
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxHashSet};
3333
use rustc_data_structures::stable_hasher::{HashStable, HashStableEq, StableHasher};
3434
use rustc_data_structures::tagged_ptr::CopyTaggedPtr;
3535
use rustc_hir as hir;
@@ -43,7 +43,7 @@ use rustc_span::symbol::{kw, Ident, Symbol};
4343
use rustc_span::{sym, Span};
4444
use rustc_target::abi::Align;
4545

46-
use std::hash::Hash;
46+
use std::hash::{Hash, Hasher};
4747
use std::ops::ControlFlow;
4848
use std::{fmt, str};
4949

@@ -444,31 +444,23 @@ static BOOL_TYS: TyS<'static> = TyS {
444444
outer_exclusive_binder: DebruijnIndex::from_usize(0),
445445
};
446446

447-
impl<'tcx> PartialEq for TyS<'tcx> {
448-
#[inline]
449-
fn eq(&self, other: &TyS<'tcx>) -> bool {
450-
// Pointer equality implies equality (due to the unique contents
451-
// assumption).
452-
ptr::eq(self, other)
453-
}
454-
}
455-
impl<'tcx> Eq for TyS<'tcx> {}
456-
457-
impl<'tcx> HashStableEq for TyS<'tcx> {
447+
impl<'tcx> HashStableEq for Ty<'tcx> {
458448
fn hash_stable_eq(&self, other: &Self) -> bool {
459-
self == other
460-
}
461-
}
449+
let TyS {
450+
ref kind,
451+
452+
// The other fields just provide fast access to information that is
453+
// also contained in `kind`, so no need to compare them.
454+
flags: _,
455+
456+
outer_exclusive_binder: _,
457+
} = self.0.0;
462458

463-
impl<'tcx> Hash for TyS<'tcx> {
464-
fn hash<H: Hasher>(&self, s: &mut H) {
465-
// Pointer hashing is sufficient (due to the unique contents
466-
// assumption).
467-
(self as *const TyS<'_>).hash(s)
459+
kind.hash_stable_eq(other.kind())
468460
}
469461
}
470462

471-
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TyS<'tcx> {
463+
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Ty<'tcx> {
472464
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
473465
let TyS {
474466
ref kind,

compiler/rustc_query_system/src/query/plumbing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<C: QueryCache> QueryCacheStore<C> {
6868
}
6969

7070
struct QueryStateShard<K> {
71-
active: FxHashMap<K, QueryResult>,
71+
active: FxHashMap<HashStableKey<K>, QueryResult>,
7272
}
7373

7474
#[derive(Copy, Clone, Hash)]

0 commit comments

Comments
 (0)