Skip to content

Commit 028e57b

Browse files
committed
Rename Interned as InternedInSet.
This will let us introduce a more widely-used `Interned` type in the next commit.
1 parent 0c3f0cd commit 028e57b

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

compiler/rustc_middle/src/ty/context.rs

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub trait OnDiskCache<'tcx>: rustc_data_structures::sync::Sync {
9191
#[derive(TyEncodable, TyDecodable, HashStable)]
9292
pub struct DelaySpanBugEmitted(());
9393

94-
type InternedSet<'tcx, T> = ShardedHashMap<Interned<'tcx, T>, ()>;
94+
type InternedSet<'tcx, T> = ShardedHashMap<InternedInSet<'tcx, T>, ()>;
9595

9696
pub struct CtxtInterners<'tcx> {
9797
/// The arena that types, regions, etc. are allocated from.
@@ -161,7 +161,7 @@ impl<'tcx> CtxtInterners<'tcx> {
161161
outer_exclusive_binder: flags.outer_exclusive_binder,
162162
};
163163

164-
Interned(self.arena.alloc(ty_struct))
164+
InternedInSet(self.arena.alloc(ty_struct))
165165
})
166166
.0
167167
}
@@ -181,7 +181,7 @@ impl<'tcx> CtxtInterners<'tcx> {
181181
outer_exclusive_binder: flags.outer_exclusive_binder,
182182
};
183183

184-
Interned(self.arena.alloc(predicate_struct))
184+
InternedInSet(self.arena.alloc(predicate_struct))
185185
})
186186
.0
187187
}
@@ -928,7 +928,7 @@ impl<'tcx> CommonTypes<'tcx> {
928928

929929
impl<'tcx> CommonLifetimes<'tcx> {
930930
fn new(interners: &CtxtInterners<'tcx>) -> CommonLifetimes<'tcx> {
931-
let mk = |r| interners.region.intern(r, |r| Interned(interners.arena.alloc(r))).0;
931+
let mk = |r| interners.region.intern(r, |r| InternedInSet(interners.arena.alloc(r))).0;
932932

933933
CommonLifetimes {
934934
re_root_empty: mk(RegionKind::ReEmpty(ty::UniverseIndex::ROOT)),
@@ -940,7 +940,8 @@ impl<'tcx> CommonLifetimes<'tcx> {
940940

941941
impl<'tcx> CommonConsts<'tcx> {
942942
fn new(interners: &CtxtInterners<'tcx>, types: &CommonTypes<'tcx>) -> CommonConsts<'tcx> {
943-
let mk_const = |c| interners.const_.intern(c, |c| Interned(interners.arena.alloc(c))).0;
943+
let mk_const =
944+
|c| interners.const_.intern(c, |c| InternedInSet(interners.arena.alloc(c))).0;
944945

945946
CommonConsts {
946947
unit: mk_const(ty::Const {
@@ -1632,7 +1633,7 @@ macro_rules! nop_lift {
16321633
impl<'a, 'tcx> Lift<'tcx> for $ty {
16331634
type Lifted = $lifted;
16341635
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
1635-
if tcx.interners.$set.contains_pointer_to(&Interned(self)) {
1636+
if tcx.interners.$set.contains_pointer_to(&InternedInSet(self)) {
16361637
Some(unsafe { mem::transmute(self) })
16371638
} else {
16381639
None
@@ -1650,7 +1651,7 @@ macro_rules! nop_list_lift {
16501651
if self.is_empty() {
16511652
return Some(List::empty());
16521653
}
1653-
if tcx.interners.$set.contains_pointer_to(&Interned(self)) {
1654+
if tcx.interners.$set.contains_pointer_to(&InternedInSet(self)) {
16541655
Some(unsafe { mem::transmute(self) })
16551656
} else {
16561657
None
@@ -1857,7 +1858,7 @@ macro_rules! sty_debug_print {
18571858
#[allow(non_snake_case)]
18581859
mod inner {
18591860
use crate::ty::{self, TyCtxt};
1860-
use crate::ty::context::Interned;
1861+
use crate::ty::context::InternedInSet;
18611862

18621863
#[derive(Copy, Clone)]
18631864
struct DebugStat {
@@ -1880,7 +1881,7 @@ macro_rules! sty_debug_print {
18801881

18811882
let shards = tcx.interners.type_.lock_shards();
18821883
let types = shards.iter().flat_map(|shard| shard.keys());
1883-
for &Interned(t) in types {
1884+
for &InternedInSet(t) in types {
18841885
let variant = match t.kind() {
18851886
ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) |
18861887
ty::Float(..) | ty::Str | ty::Never => continue,
@@ -1980,86 +1981,86 @@ impl<'tcx> TyCtxt<'tcx> {
19801981
// this type just holds a pointer to it, but it still effectively owns it. It
19811982
// impls `Borrow` so that it can be looked up using the original
19821983
// (non-arena-memory-owning) types.
1983-
struct Interned<'tcx, T: ?Sized>(&'tcx T);
1984+
struct InternedInSet<'tcx, T: ?Sized>(&'tcx T);
19841985

1985-
impl<'tcx, T: 'tcx + ?Sized> Clone for Interned<'tcx, T> {
1986+
impl<'tcx, T: 'tcx + ?Sized> Clone for InternedInSet<'tcx, T> {
19861987
fn clone(&self) -> Self {
1987-
Interned(self.0)
1988+
InternedInSet(self.0)
19881989
}
19891990
}
19901991

1991-
impl<'tcx, T: 'tcx + ?Sized> Copy for Interned<'tcx, T> {}
1992+
impl<'tcx, T: 'tcx + ?Sized> Copy for InternedInSet<'tcx, T> {}
19921993

1993-
impl<'tcx, T: 'tcx + ?Sized> IntoPointer for Interned<'tcx, T> {
1994+
impl<'tcx, T: 'tcx + ?Sized> IntoPointer for InternedInSet<'tcx, T> {
19941995
fn into_pointer(&self) -> *const () {
19951996
self.0 as *const _ as *const ()
19961997
}
19971998
}
19981999

19992000
#[allow(rustc::usage_of_ty_tykind)]
2000-
impl<'tcx> Borrow<TyKind<'tcx>> for Interned<'tcx, TyS<'tcx>> {
2001+
impl<'tcx> Borrow<TyKind<'tcx>> for InternedInSet<'tcx, TyS<'tcx>> {
20012002
fn borrow<'a>(&'a self) -> &'a TyKind<'tcx> {
20022003
&self.0.kind()
20032004
}
20042005
}
20052006

2006-
impl<'tcx> PartialEq for Interned<'tcx, TyS<'tcx>> {
2007-
fn eq(&self, other: &Interned<'tcx, TyS<'tcx>>) -> bool {
2007+
impl<'tcx> PartialEq for InternedInSet<'tcx, TyS<'tcx>> {
2008+
fn eq(&self, other: &InternedInSet<'tcx, TyS<'tcx>>) -> bool {
20082009
// The `Borrow` trait requires that `x.borrow() == y.borrow()` equals
20092010
// `x == y`.
20102011
self.0.kind() == other.0.kind()
20112012
}
20122013
}
20132014

2014-
impl<'tcx> Eq for Interned<'tcx, TyS<'tcx>> {}
2015+
impl<'tcx> Eq for InternedInSet<'tcx, TyS<'tcx>> {}
20152016

2016-
impl<'tcx> Hash for Interned<'tcx, TyS<'tcx>> {
2017+
impl<'tcx> Hash for InternedInSet<'tcx, TyS<'tcx>> {
20172018
fn hash<H: Hasher>(&self, s: &mut H) {
20182019
// The `Borrow` trait requires that `x.borrow().hash(s) == x.hash(s)`.
20192020
self.0.kind().hash(s)
20202021
}
20212022
}
20222023

2023-
impl<'tcx> Borrow<Binder<'tcx, PredicateKind<'tcx>>> for Interned<'tcx, PredicateInner<'tcx>> {
2024+
impl<'tcx> Borrow<Binder<'tcx, PredicateKind<'tcx>>> for InternedInSet<'tcx, PredicateInner<'tcx>> {
20242025
fn borrow<'a>(&'a self) -> &'a Binder<'tcx, PredicateKind<'tcx>> {
20252026
&self.0.kind
20262027
}
20272028
}
20282029

2029-
impl<'tcx> PartialEq for Interned<'tcx, PredicateInner<'tcx>> {
2030-
fn eq(&self, other: &Interned<'tcx, PredicateInner<'tcx>>) -> bool {
2030+
impl<'tcx> PartialEq for InternedInSet<'tcx, PredicateInner<'tcx>> {
2031+
fn eq(&self, other: &InternedInSet<'tcx, PredicateInner<'tcx>>) -> bool {
20312032
// The `Borrow` trait requires that `x.borrow() == y.borrow()` equals
20322033
// `x == y`.
20332034
self.0.kind == other.0.kind
20342035
}
20352036
}
20362037

2037-
impl<'tcx> Eq for Interned<'tcx, PredicateInner<'tcx>> {}
2038+
impl<'tcx> Eq for InternedInSet<'tcx, PredicateInner<'tcx>> {}
20382039

2039-
impl<'tcx> Hash for Interned<'tcx, PredicateInner<'tcx>> {
2040+
impl<'tcx> Hash for InternedInSet<'tcx, PredicateInner<'tcx>> {
20402041
fn hash<H: Hasher>(&self, s: &mut H) {
20412042
// The `Borrow` trait requires that `x.borrow().hash(s) == x.hash(s)`.
20422043
self.0.kind.hash(s)
20432044
}
20442045
}
20452046

2046-
impl<'tcx, T> Borrow<[T]> for Interned<'tcx, List<T>> {
2047+
impl<'tcx, T> Borrow<[T]> for InternedInSet<'tcx, List<T>> {
20472048
fn borrow<'a>(&'a self) -> &'a [T] {
20482049
&self.0[..]
20492050
}
20502051
}
20512052

2052-
impl<'tcx, T: PartialEq> PartialEq for Interned<'tcx, List<T>> {
2053-
fn eq(&self, other: &Interned<'tcx, List<T>>) -> bool {
2053+
impl<'tcx, T: PartialEq> PartialEq for InternedInSet<'tcx, List<T>> {
2054+
fn eq(&self, other: &InternedInSet<'tcx, List<T>>) -> bool {
20542055
// The `Borrow` trait requires that `x.borrow() == y.borrow()` equals
20552056
// `x == y`.
20562057
self.0[..] == other.0[..]
20572058
}
20582059
}
20592060

2060-
impl<'tcx, T: Eq> Eq for Interned<'tcx, List<T>> {}
2061+
impl<'tcx, T: Eq> Eq for InternedInSet<'tcx, List<T>> {}
20612062

2062-
impl<'tcx, T: Hash> Hash for Interned<'tcx, List<T>> {
2063+
impl<'tcx, T: Hash> Hash for InternedInSet<'tcx, List<T>> {
20632064
fn hash<H: Hasher>(&self, s: &mut H) {
20642065
// The `Borrow` trait requires that `x.borrow().hash(s) == x.hash(s)`.
20652066
self.0[..].hash(s)
@@ -2068,23 +2069,23 @@ impl<'tcx, T: Hash> Hash for Interned<'tcx, List<T>> {
20682069

20692070
macro_rules! direct_interners {
20702071
($($name:ident: $method:ident($ty:ty),)+) => {
2071-
$(impl<'tcx> Borrow<$ty> for Interned<'tcx, $ty> {
2072+
$(impl<'tcx> Borrow<$ty> for InternedInSet<'tcx, $ty> {
20722073
fn borrow<'a>(&'a self) -> &'a $ty {
20732074
&self.0
20742075
}
20752076
}
20762077

2077-
impl<'tcx> PartialEq for Interned<'tcx, $ty> {
2078+
impl<'tcx> PartialEq for InternedInSet<'tcx, $ty> {
20782079
fn eq(&self, other: &Self) -> bool {
20792080
// The `Borrow` trait requires that `x.borrow() == y.borrow()`
20802081
// equals `x == y`.
20812082
self.0 == other.0
20822083
}
20832084
}
20842085

2085-
impl<'tcx> Eq for Interned<'tcx, $ty> {}
2086+
impl<'tcx> Eq for InternedInSet<'tcx, $ty> {}
20862087

2087-
impl<'tcx> Hash for Interned<'tcx, $ty> {
2088+
impl<'tcx> Hash for InternedInSet<'tcx, $ty> {
20882089
fn hash<H: Hasher>(&self, s: &mut H) {
20892090
// The `Borrow` trait requires that `x.borrow().hash(s) ==
20902091
// x.hash(s)`.
@@ -2095,7 +2096,7 @@ macro_rules! direct_interners {
20952096
impl<'tcx> TyCtxt<'tcx> {
20962097
pub fn $method(self, v: $ty) -> &'tcx $ty {
20972098
self.interners.$name.intern(v, |v| {
2098-
Interned(self.interners.arena.alloc(v))
2099+
InternedInSet(self.interners.arena.alloc(v))
20992100
}).0
21002101
}
21012102
})+
@@ -2117,7 +2118,7 @@ macro_rules! slice_interners {
21172118
impl<'tcx> TyCtxt<'tcx> {
21182119
$(pub fn $method(self, v: &[$ty]) -> &'tcx List<$ty> {
21192120
self.interners.$field.intern_ref(v, || {
2120-
Interned(List::from_arena(&*self.arena, v))
2121+
InternedInSet(List::from_arena(&*self.arena, v))
21212122
}).0
21222123
})+
21232124
}

0 commit comments

Comments
 (0)