Skip to content

Commit 3d31e5c

Browse files
committed
s/WithStableHash/WithCachedTypeInfo/
1 parent 8de4b13 commit 3d31e5c

File tree

5 files changed

+45
-44
lines changed

5 files changed

+45
-44
lines changed

compiler/rustc_data_structures/src/intern.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,33 +118,33 @@ where
118118
/// This is useful if you have values that you intern but never (can?) use for stable
119119
/// hashing.
120120
#[derive(Copy, Clone)]
121-
pub struct WithStableHash<T> {
121+
pub struct WithCachedTypeInfo<T> {
122122
pub internee: T,
123123
pub stable_hash: Fingerprint,
124124
}
125125

126-
impl<T: PartialEq> PartialEq for WithStableHash<T> {
126+
impl<T: PartialEq> PartialEq for WithCachedTypeInfo<T> {
127127
#[inline]
128128
fn eq(&self, other: &Self) -> bool {
129129
self.internee.eq(&other.internee)
130130
}
131131
}
132132

133-
impl<T: Eq> Eq for WithStableHash<T> {}
133+
impl<T: Eq> Eq for WithCachedTypeInfo<T> {}
134134

135-
impl<T: Ord> PartialOrd for WithStableHash<T> {
136-
fn partial_cmp(&self, other: &WithStableHash<T>) -> Option<Ordering> {
135+
impl<T: Ord> PartialOrd for WithCachedTypeInfo<T> {
136+
fn partial_cmp(&self, other: &WithCachedTypeInfo<T>) -> Option<Ordering> {
137137
Some(self.internee.cmp(&other.internee))
138138
}
139139
}
140140

141-
impl<T: Ord> Ord for WithStableHash<T> {
142-
fn cmp(&self, other: &WithStableHash<T>) -> Ordering {
141+
impl<T: Ord> Ord for WithCachedTypeInfo<T> {
142+
fn cmp(&self, other: &WithCachedTypeInfo<T>) -> Ordering {
143143
self.internee.cmp(&other.internee)
144144
}
145145
}
146146

147-
impl<T> Deref for WithStableHash<T> {
147+
impl<T> Deref for WithCachedTypeInfo<T> {
148148
type Target = T;
149149

150150
#[inline]
@@ -153,7 +153,7 @@ impl<T> Deref for WithStableHash<T> {
153153
}
154154
}
155155

156-
impl<T: Hash> Hash for WithStableHash<T> {
156+
impl<T: Hash> Hash for WithCachedTypeInfo<T> {
157157
#[inline]
158158
fn hash<H: Hasher>(&self, s: &mut H) {
159159
if self.stable_hash != Fingerprint::ZERO {
@@ -164,7 +164,7 @@ impl<T: Hash> Hash for WithStableHash<T> {
164164
}
165165
}
166166

167-
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for WithStableHash<T> {
167+
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for WithCachedTypeInfo<T> {
168168
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
169169
if self.stable_hash == Fingerprint::ZERO || cfg!(debug_assertions) {
170170
// No cached hash available. This can only mean that incremental is disabled.

compiler/rustc_middle/src/arena.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ macro_rules! arena_types {
8888
[] hir_id_set: rustc_hir::HirIdSet,
8989

9090
// Interned types
91-
[] tys: rustc_data_structures::intern::WithStableHash<rustc_middle::ty::TyS<'tcx>>,
92-
[] predicates: rustc_data_structures::intern::WithStableHash<rustc_middle::ty::PredicateS<'tcx>>,
91+
[] tys: rustc_data_structures::intern::WithCachedTypeInfo<rustc_middle::ty::TyS<'tcx>>,
92+
[] predicates: rustc_data_structures::intern::WithCachedTypeInfo<rustc_middle::ty::PredicateS<'tcx>>,
9393
[] consts: rustc_middle::ty::ConstS<'tcx>,
9494

9595
// Note that this deliberately duplicates items in the `rustc_hir::arena`,

compiler/rustc_middle/src/ty/context.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::ty::{GenericArg, GenericArgKind, InternalSubsts, SubstsRef, UserSubst
2727
use rustc_ast as ast;
2828
use rustc_data_structures::fingerprint::Fingerprint;
2929
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
30-
use rustc_data_structures::intern::{Interned, WithStableHash};
30+
use rustc_data_structures::intern::{Interned, WithCachedTypeInfo};
3131
use rustc_data_structures::memmap::Mmap;
3232
use rustc_data_structures::profiling::SelfProfilerRef;
3333
use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
@@ -136,13 +136,13 @@ pub struct CtxtInterners<'tcx> {
136136

137137
// Specifically use a speedy hash algorithm for these hash sets, since
138138
// they're accessed quite often.
139-
type_: InternedSet<'tcx, WithStableHash<TyS<'tcx>>>,
139+
type_: InternedSet<'tcx, WithCachedTypeInfo<TyS<'tcx>>>,
140140
const_lists: InternedSet<'tcx, List<ty::Const<'tcx>>>,
141141
substs: InternedSet<'tcx, InternalSubsts<'tcx>>,
142142
canonical_var_infos: InternedSet<'tcx, List<CanonicalVarInfo<'tcx>>>,
143143
region: InternedSet<'tcx, RegionKind<'tcx>>,
144144
poly_existential_predicates: InternedSet<'tcx, List<PolyExistentialPredicate<'tcx>>>,
145-
predicate: InternedSet<'tcx, WithStableHash<PredicateS<'tcx>>>,
145+
predicate: InternedSet<'tcx, WithCachedTypeInfo<PredicateS<'tcx>>>,
146146
predicates: InternedSet<'tcx, List<Predicate<'tcx>>>,
147147
projs: InternedSet<'tcx, List<ProjectionKind>>,
148148
place_elems: InternedSet<'tcx, List<PlaceElem<'tcx>>>,
@@ -200,7 +200,7 @@ impl<'tcx> CtxtInterners<'tcx> {
200200
};
201201

202202
InternedInSet(
203-
self.arena.alloc(WithStableHash { internee: ty_struct, stable_hash }),
203+
self.arena.alloc(WithCachedTypeInfo { internee: ty_struct, stable_hash }),
204204
)
205205
})
206206
.0,
@@ -253,7 +253,7 @@ impl<'tcx> CtxtInterners<'tcx> {
253253

254254
InternedInSet(
255255
self.arena
256-
.alloc(WithStableHash { internee: predicate_struct, stable_hash }),
256+
.alloc(WithCachedTypeInfo { internee: predicate_struct, stable_hash }),
257257
)
258258
})
259259
.0,
@@ -2167,48 +2167,48 @@ impl<'tcx, T: 'tcx + ?Sized> IntoPointer for InternedInSet<'tcx, T> {
21672167
}
21682168

21692169
#[allow(rustc::usage_of_ty_tykind)]
2170-
impl<'tcx> Borrow<TyKind<'tcx>> for InternedInSet<'tcx, WithStableHash<TyS<'tcx>>> {
2170+
impl<'tcx> Borrow<TyKind<'tcx>> for InternedInSet<'tcx, WithCachedTypeInfo<TyS<'tcx>>> {
21712171
fn borrow<'a>(&'a self) -> &'a TyKind<'tcx> {
21722172
&self.0.kind
21732173
}
21742174
}
21752175

2176-
impl<'tcx> PartialEq for InternedInSet<'tcx, WithStableHash<TyS<'tcx>>> {
2177-
fn eq(&self, other: &InternedInSet<'tcx, WithStableHash<TyS<'tcx>>>) -> bool {
2176+
impl<'tcx> PartialEq for InternedInSet<'tcx, WithCachedTypeInfo<TyS<'tcx>>> {
2177+
fn eq(&self, other: &InternedInSet<'tcx, WithCachedTypeInfo<TyS<'tcx>>>) -> bool {
21782178
// The `Borrow` trait requires that `x.borrow() == y.borrow()` equals
21792179
// `x == y`.
21802180
self.0.kind == other.0.kind
21812181
}
21822182
}
21832183

2184-
impl<'tcx> Eq for InternedInSet<'tcx, WithStableHash<TyS<'tcx>>> {}
2184+
impl<'tcx> Eq for InternedInSet<'tcx, WithCachedTypeInfo<TyS<'tcx>>> {}
21852185

2186-
impl<'tcx> Hash for InternedInSet<'tcx, WithStableHash<TyS<'tcx>>> {
2186+
impl<'tcx> Hash for InternedInSet<'tcx, WithCachedTypeInfo<TyS<'tcx>>> {
21872187
fn hash<H: Hasher>(&self, s: &mut H) {
21882188
// The `Borrow` trait requires that `x.borrow().hash(s) == x.hash(s)`.
21892189
self.0.kind.hash(s)
21902190
}
21912191
}
21922192

21932193
impl<'tcx> Borrow<Binder<'tcx, PredicateKind<'tcx>>>
2194-
for InternedInSet<'tcx, WithStableHash<PredicateS<'tcx>>>
2194+
for InternedInSet<'tcx, WithCachedTypeInfo<PredicateS<'tcx>>>
21952195
{
21962196
fn borrow<'a>(&'a self) -> &'a Binder<'tcx, PredicateKind<'tcx>> {
21972197
&self.0.kind
21982198
}
21992199
}
22002200

2201-
impl<'tcx> PartialEq for InternedInSet<'tcx, WithStableHash<PredicateS<'tcx>>> {
2202-
fn eq(&self, other: &InternedInSet<'tcx, WithStableHash<PredicateS<'tcx>>>) -> bool {
2201+
impl<'tcx> PartialEq for InternedInSet<'tcx, WithCachedTypeInfo<PredicateS<'tcx>>> {
2202+
fn eq(&self, other: &InternedInSet<'tcx, WithCachedTypeInfo<PredicateS<'tcx>>>) -> bool {
22032203
// The `Borrow` trait requires that `x.borrow() == y.borrow()` equals
22042204
// `x == y`.
22052205
self.0.kind == other.0.kind
22062206
}
22072207
}
22082208

2209-
impl<'tcx> Eq for InternedInSet<'tcx, WithStableHash<PredicateS<'tcx>>> {}
2209+
impl<'tcx> Eq for InternedInSet<'tcx, WithCachedTypeInfo<PredicateS<'tcx>>> {}
22102210

2211-
impl<'tcx> Hash for InternedInSet<'tcx, WithStableHash<PredicateS<'tcx>>> {
2211+
impl<'tcx> Hash for InternedInSet<'tcx, WithCachedTypeInfo<PredicateS<'tcx>>> {
22122212
fn hash<H: Hasher>(&self, s: &mut H) {
22132213
// The `Borrow` trait requires that `x.borrow().hash(s) == x.hash(s)`.
22142214
self.0.kind.hash(s)

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use rustc_ast::node_id::NodeMap;
3232
use rustc_attr as attr;
3333
use rustc_data_structures::fingerprint::Fingerprint;
3434
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
35-
use rustc_data_structures::intern::{Interned, WithStableHash};
35+
use rustc_data_structures::intern::{Interned, WithCachedTypeInfo};
3636
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
3737
use rustc_data_structures::tagged_ptr::CopyTaggedPtr;
3838
use rustc_hir as hir;
@@ -495,19 +495,20 @@ pub(crate) struct TyS<'tcx> {
495495
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)]
496496
#[rustc_diagnostic_item = "Ty"]
497497
#[rustc_pass_by_value]
498-
pub struct Ty<'tcx>(Interned<'tcx, WithStableHash<TyS<'tcx>>>);
498+
pub struct Ty<'tcx>(Interned<'tcx, WithCachedTypeInfo<TyS<'tcx>>>);
499499

500500
impl<'tcx> TyCtxt<'tcx> {
501501
/// A "bool" type used in rustc_mir_transform unit tests when we
502502
/// have not spun up a TyCtxt.
503-
pub const BOOL_TY_FOR_UNIT_TESTING: Ty<'tcx> = Ty(Interned::new_unchecked(&WithStableHash {
504-
internee: TyS {
505-
kind: ty::Bool,
506-
flags: TypeFlags::empty(),
507-
outer_exclusive_binder: DebruijnIndex::from_usize(0),
508-
},
509-
stable_hash: Fingerprint::ZERO,
510-
}));
503+
pub const BOOL_TY_FOR_UNIT_TESTING: Ty<'tcx> =
504+
Ty(Interned::new_unchecked(&WithCachedTypeInfo {
505+
internee: TyS {
506+
kind: ty::Bool,
507+
flags: TypeFlags::empty(),
508+
outer_exclusive_binder: DebruijnIndex::from_usize(0),
509+
},
510+
stable_hash: Fingerprint::ZERO,
511+
}));
511512
}
512513

513514
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TyS<'tcx> {
@@ -550,7 +551,7 @@ pub(crate) struct PredicateS<'tcx> {
550551
/// Use this rather than `PredicateS`, whenever possible.
551552
#[derive(Clone, Copy, PartialEq, Eq, Hash, HashStable)]
552553
#[rustc_pass_by_value]
553-
pub struct Predicate<'tcx>(Interned<'tcx, WithStableHash<PredicateS<'tcx>>>);
554+
pub struct Predicate<'tcx>(Interned<'tcx, WithCachedTypeInfo<PredicateS<'tcx>>>);
554555

555556
impl<'tcx> Predicate<'tcx> {
556557
/// Gets the inner `Binder<'tcx, PredicateKind<'tcx>>`.
@@ -1028,7 +1029,7 @@ impl<'tcx> Term<'tcx> {
10281029
unsafe {
10291030
match ptr & TAG_MASK {
10301031
TYPE_TAG => TermKind::Ty(Ty(Interned::new_unchecked(
1031-
&*((ptr & !TAG_MASK) as *const WithStableHash<ty::TyS<'tcx>>),
1032+
&*((ptr & !TAG_MASK) as *const WithCachedTypeInfo<ty::TyS<'tcx>>),
10321033
))),
10331034
CONST_TAG => TermKind::Const(ty::Const(Interned::new_unchecked(
10341035
&*((ptr & !TAG_MASK) as *const ty::ConstS<'tcx>),
@@ -1072,7 +1073,7 @@ impl<'tcx> TermKind<'tcx> {
10721073
TermKind::Ty(ty) => {
10731074
// Ensure we can use the tag bits.
10741075
assert_eq!(mem::align_of_val(&*ty.0.0) & TAG_MASK, 0);
1075-
(TYPE_TAG, ty.0.0 as *const WithStableHash<ty::TyS<'tcx>> as usize)
1076+
(TYPE_TAG, ty.0.0 as *const WithCachedTypeInfo<ty::TyS<'tcx>> as usize)
10761077
}
10771078
TermKind::Const(ct) => {
10781079
// Ensure we can use the tag bits.
@@ -2694,6 +2695,6 @@ mod size_asserts {
26942695
// tidy-alphabetical-start
26952696
static_assert_size!(PredicateS<'_>, 48);
26962697
static_assert_size!(TyS<'_>, 40);
2697-
static_assert_size!(WithStableHash<TyS<'_>>, 56);
2698+
static_assert_size!(WithCachedTypeInfo<TyS<'_>>, 56);
26982699
// tidy-alphabetical-end
26992700
}

compiler/rustc_middle/src/ty/subst.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::ty::sty::{ClosureSubsts, GeneratorSubsts, InlineConstSubsts};
66
use crate::ty::visit::{TypeVisitable, TypeVisitor};
77
use crate::ty::{self, Lift, List, ParamConst, Ty, TyCtxt};
88

9-
use rustc_data_structures::intern::{Interned, WithStableHash};
9+
use rustc_data_structures::intern::{Interned, WithCachedTypeInfo};
1010
use rustc_hir::def_id::DefId;
1111
use rustc_macros::HashStable;
1212
use rustc_serialize::{self, Decodable, Encodable};
@@ -84,7 +84,7 @@ impl<'tcx> GenericArgKind<'tcx> {
8484
GenericArgKind::Type(ty) => {
8585
// Ensure we can use the tag bits.
8686
assert_eq!(mem::align_of_val(&*ty.0.0) & TAG_MASK, 0);
87-
(TYPE_TAG, ty.0.0 as *const WithStableHash<ty::TyS<'tcx>> as usize)
87+
(TYPE_TAG, ty.0.0 as *const WithCachedTypeInfo<ty::TyS<'tcx>> as usize)
8888
}
8989
GenericArgKind::Const(ct) => {
9090
// Ensure we can use the tag bits.
@@ -162,7 +162,7 @@ impl<'tcx> GenericArg<'tcx> {
162162
&*((ptr & !TAG_MASK) as *const ty::RegionKind<'tcx>),
163163
))),
164164
TYPE_TAG => GenericArgKind::Type(Ty(Interned::new_unchecked(
165-
&*((ptr & !TAG_MASK) as *const WithStableHash<ty::TyS<'tcx>>),
165+
&*((ptr & !TAG_MASK) as *const WithCachedTypeInfo<ty::TyS<'tcx>>),
166166
))),
167167
CONST_TAG => GenericArgKind::Const(ty::Const(Interned::new_unchecked(
168168
&*((ptr & !TAG_MASK) as *const ty::ConstS<'tcx>),

0 commit comments

Comments
 (0)