Skip to content

Commit 189e6a8

Browse files
Some renaming nits for rustc_type_ir
1 parent 8d20182 commit 189e6a8

File tree

4 files changed

+61
-52
lines changed

4 files changed

+61
-52
lines changed

compiler/rustc_middle/src/ty/context.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -80,42 +80,40 @@ use std::ops::{Bound, Deref};
8080

8181
#[allow(rustc::usage_of_ty_tykind)]
8282
impl<'tcx> Interner for TyCtxt<'tcx> {
83+
type DefId = DefId;
8384
type AdtDef = ty::AdtDef<'tcx>;
84-
type GenericArgsRef = ty::GenericArgsRef<'tcx>;
85+
type GenericArgs = ty::GenericArgsRef<'tcx>;
8586
type GenericArg = ty::GenericArg<'tcx>;
86-
type DefId = DefId;
8787
type Binder<T> = Binder<'tcx, T>;
88-
type Ty = Ty<'tcx>;
89-
type Const = ty::Const<'tcx>;
90-
type Region = Region<'tcx>;
9188
type Predicate = Predicate<'tcx>;
89+
type PredicateKind = ty::PredicateKind<'tcx>;
9290
type TypeAndMut = TypeAndMut<'tcx>;
9391
type Mutability = hir::Mutability;
9492
type Movability = hir::Movability;
95-
type PolyFnSig = PolyFnSig<'tcx>;
96-
type ListBinderExistentialPredicate = &'tcx List<PolyExistentialPredicate<'tcx>>;
97-
type ListTy = &'tcx List<Ty<'tcx>>;
93+
type Ty = Ty<'tcx>;
94+
type Tys = &'tcx List<Ty<'tcx>>;
9895
type AliasTy = ty::AliasTy<'tcx>;
9996
type ParamTy = ParamTy;
10097
type BoundTy = ty::BoundTy;
101-
type PlaceholderType = ty::PlaceholderType;
98+
type PlaceholderTy = ty::PlaceholderType;
10299
type InferTy = InferTy;
103100
type ErrorGuaranteed = ErrorGuaranteed;
104-
type PredicateKind = ty::PredicateKind<'tcx>;
101+
type BoundExistentialPredicates = &'tcx List<PolyExistentialPredicate<'tcx>>;
102+
type PolyFnSig = PolyFnSig<'tcx>;
105103
type AllocId = crate::mir::interpret::AllocId;
106-
104+
type Const = ty::Const<'tcx>;
107105
type InferConst = ty::InferConst<'tcx>;
108106
type AliasConst = ty::UnevaluatedConst<'tcx>;
107+
type PlaceholderConst = ty::PlaceholderConst<'tcx>;
109108
type ParamConst = ty::ParamConst;
110109
type BoundConst = ty::BoundVar;
111-
type PlaceholderConst = ty::PlaceholderConst<'tcx>;
112110
type ValueConst = ty::ValTree<'tcx>;
113111
type ExprConst = ty::Expr<'tcx>;
114-
112+
type Region = Region<'tcx>;
115113
type EarlyBoundRegion = ty::EarlyBoundRegion;
116114
type BoundRegion = ty::BoundRegion;
117115
type FreeRegion = ty::FreeRegion;
118-
type RegionVid = ty::RegionVid;
116+
type InferRegion = ty::RegionVid;
119117
type PlaceholderRegion = ty::PlaceholderRegion;
120118

121119
fn ty_and_mut_to_parts(

compiler/rustc_type_ir/src/lib.rs

+22-11
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,43 @@ pub use ty_info::*;
4242
pub trait HashStableContext {}
4343

4444
pub trait Interner: Sized {
45+
type DefId: Clone + Debug + Hash + Ord;
4546
type AdtDef: Clone + Debug + Hash + Ord;
46-
type GenericArgsRef: Clone
47+
48+
type GenericArgs: Clone
4749
+ DebugWithInfcx<Self>
4850
+ Hash
4951
+ Ord
5052
+ IntoIterator<Item = Self::GenericArg>;
5153
type GenericArg: Clone + DebugWithInfcx<Self> + Hash + Ord;
52-
type DefId: Clone + Debug + Hash + Ord;
54+
5355
type Binder<T>;
54-
type Ty: Clone + DebugWithInfcx<Self> + Hash + Ord;
55-
type Const: Clone + DebugWithInfcx<Self> + Hash + Ord;
56-
type Region: Clone + DebugWithInfcx<Self> + Hash + Ord;
56+
57+
// Predicates
5758
type Predicate;
59+
type PredicateKind: Clone + Debug + Hash + PartialEq + Eq;
60+
5861
type TypeAndMut: Clone + Debug + Hash + Ord;
5962
type Mutability: Clone + Debug + Hash + Ord;
6063
type Movability: Clone + Debug + Hash + Ord;
61-
type PolyFnSig: Clone + DebugWithInfcx<Self> + Hash + Ord;
62-
type ListBinderExistentialPredicate: Clone + DebugWithInfcx<Self> + Hash + Ord;
63-
type ListTy: Clone + Debug + Hash + Ord + IntoIterator<Item = Self::Ty>;
64+
65+
// Kinds of tys
66+
type Ty: Clone + DebugWithInfcx<Self> + Hash + Ord;
67+
type Tys: Clone + Debug + Hash + Ord + IntoIterator<Item = Self::Ty>;
6468
type AliasTy: Clone + DebugWithInfcx<Self> + Hash + Ord;
6569
type ParamTy: Clone + Debug + Hash + Ord;
6670
type BoundTy: Clone + Debug + Hash + Ord;
67-
type PlaceholderType: Clone + Debug + Hash + Ord;
71+
type PlaceholderTy: Clone + Debug + Hash + Ord;
6872
type InferTy: Clone + DebugWithInfcx<Self> + Hash + Ord;
73+
74+
// Things stored inside of tys
6975
type ErrorGuaranteed: Clone + Debug + Hash + Ord;
70-
type PredicateKind: Clone + Debug + Hash + PartialEq + Eq;
76+
type BoundExistentialPredicates: Clone + DebugWithInfcx<Self> + Hash + Ord;
77+
type PolyFnSig: Clone + DebugWithInfcx<Self> + Hash + Ord;
7178
type AllocId: Clone + Debug + Hash + Ord;
7279

80+
// Kinds of consts
81+
type Const: Clone + DebugWithInfcx<Self> + Hash + Ord;
7382
type InferConst: Clone + DebugWithInfcx<Self> + Hash + Ord;
7483
type AliasConst: Clone + DebugWithInfcx<Self> + Hash + Ord;
7584
type PlaceholderConst: Clone + Debug + Hash + Ord;
@@ -78,10 +87,12 @@ pub trait Interner: Sized {
7887
type ValueConst: Clone + Debug + Hash + Ord;
7988
type ExprConst: Clone + DebugWithInfcx<Self> + Hash + Ord;
8089

90+
// Kinds of regions
91+
type Region: Clone + DebugWithInfcx<Self> + Hash + Ord;
8192
type EarlyBoundRegion: Clone + Debug + Hash + Ord;
8293
type BoundRegion: Clone + Debug + Hash + Ord;
8394
type FreeRegion: Clone + Debug + Hash + Ord;
84-
type RegionVid: Clone + DebugWithInfcx<Self> + Hash + Ord;
95+
type InferRegion: Clone + DebugWithInfcx<Self> + Hash + Ord;
8596
type PlaceholderRegion: Clone + Debug + Hash + Ord;
8697

8798
fn ty_and_mut_to_parts(ty_and_mut: Self::TypeAndMut) -> (Self::Ty, Self::Mutability);

compiler/rustc_type_ir/src/structural_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl<I: Interner, T: TypeVisitable<I>, Ix: Idx> TypeVisitable<I> for IndexVec<Ix
208208

209209
pub trait InferCtxtLike<I: Interner> {
210210
fn universe_of_ty(&self, ty: I::InferTy) -> Option<UniverseIndex>;
211-
fn universe_of_lt(&self, lt: I::RegionVid) -> Option<UniverseIndex>;
211+
fn universe_of_lt(&self, lt: I::InferRegion) -> Option<UniverseIndex>;
212212
fn universe_of_ct(&self, ct: I::InferConst) -> Option<UniverseIndex>;
213213
}
214214

@@ -219,7 +219,7 @@ impl<I: Interner> InferCtxtLike<I> for core::convert::Infallible {
219219
fn universe_of_ct(&self, _ct: <I as Interner>::InferConst) -> Option<UniverseIndex> {
220220
match *self {}
221221
}
222-
fn universe_of_lt(&self, _lt: <I as Interner>::RegionVid) -> Option<UniverseIndex> {
222+
fn universe_of_lt(&self, _lt: <I as Interner>::InferRegion) -> Option<UniverseIndex> {
223223
match *self {}
224224
}
225225
}

compiler/rustc_type_ir/src/sty.rs

+25-25
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub enum TyKind<I: Interner> {
7979
///
8080
/// Note that generic parameters in fields only get lazily substituted
8181
/// by using something like `adt_def.all_fields().map(|field| field.ty(tcx, args))`.
82-
Adt(I::AdtDef, I::GenericArgsRef),
82+
Adt(I::AdtDef, I::GenericArgs),
8383

8484
/// An unsized FFI type that is opaque to Rust. Written as `extern type T`.
8585
Foreign(I::DefId),
@@ -111,7 +111,7 @@ pub enum TyKind<I: Interner> {
111111
/// fn foo() -> i32 { 1 }
112112
/// let bar = foo; // bar: fn() -> i32 {foo}
113113
/// ```
114-
FnDef(I::DefId, I::GenericArgsRef),
114+
FnDef(I::DefId, I::GenericArgs),
115115

116116
/// A pointer to a function. Written as `fn() -> i32`.
117117
///
@@ -127,21 +127,21 @@ pub enum TyKind<I: Interner> {
127127
FnPtr(I::PolyFnSig),
128128

129129
/// A trait object. Written as `dyn for<'b> Trait<'b, Assoc = u32> + Send + 'a`.
130-
Dynamic(I::ListBinderExistentialPredicate, I::Region, DynKind),
130+
Dynamic(I::BoundExistentialPredicates, I::Region, DynKind),
131131

132132
/// The anonymous type of a closure. Used to represent the type of `|a| a`.
133133
///
134134
/// Closure args contain both the - potentially substituted - generic parameters
135135
/// of its parent and some synthetic parameters. See the documentation for
136136
/// `ClosureArgs` for more details.
137-
Closure(I::DefId, I::GenericArgsRef),
137+
Closure(I::DefId, I::GenericArgs),
138138

139139
/// The anonymous type of a generator. Used to represent the type of
140140
/// `|a| yield a`.
141141
///
142142
/// For more info about generator args, visit the documentation for
143143
/// `GeneratorArgs`.
144-
Generator(I::DefId, I::GenericArgsRef, I::Movability),
144+
Generator(I::DefId, I::GenericArgs, I::Movability),
145145

146146
/// A type representing the types stored inside a generator.
147147
/// This should only appear as part of the `GeneratorArgs`.
@@ -167,13 +167,13 @@ pub enum TyKind<I: Interner> {
167167
/// }
168168
/// # ;
169169
/// ```
170-
GeneratorWitness(I::DefId, I::GenericArgsRef),
170+
GeneratorWitness(I::DefId, I::GenericArgs),
171171

172172
/// The never type `!`.
173173
Never,
174174

175175
/// A tuple type. For example, `(i32, bool)`.
176-
Tuple(I::ListTy),
176+
Tuple(I::Tys),
177177

178178
/// A projection, opaque type, weak type alias, or inherent associated type.
179179
/// All of these types are represented as pairs of def-id and args, and can
@@ -209,7 +209,7 @@ pub enum TyKind<I: Interner> {
209209
/// to the bound variable's index from the binder from which it was instantiated),
210210
/// and `U` is the universe index in which it is instantiated, or totally omitted
211211
/// if the universe index is zero.
212-
Placeholder(I::PlaceholderType),
212+
Placeholder(I::PlaceholderTy),
213213

214214
/// A type variable used during type checking.
215215
///
@@ -567,7 +567,7 @@ impl<I: Interner, E: TyEncoder> Encodable<E> for TyKind<I>
567567
where
568568
I::ErrorGuaranteed: Encodable<E>,
569569
I::AdtDef: Encodable<E>,
570-
I::GenericArgsRef: Encodable<E>,
570+
I::GenericArgs: Encodable<E>,
571571
I::DefId: Encodable<E>,
572572
I::Ty: Encodable<E>,
573573
I::Const: Encodable<E>,
@@ -576,12 +576,12 @@ where
576576
I::Mutability: Encodable<E>,
577577
I::Movability: Encodable<E>,
578578
I::PolyFnSig: Encodable<E>,
579-
I::ListBinderExistentialPredicate: Encodable<E>,
580-
I::ListTy: Encodable<E>,
579+
I::BoundExistentialPredicates: Encodable<E>,
580+
I::Tys: Encodable<E>,
581581
I::AliasTy: Encodable<E>,
582582
I::ParamTy: Encodable<E>,
583583
I::BoundTy: Encodable<E>,
584-
I::PlaceholderType: Encodable<E>,
584+
I::PlaceholderTy: Encodable<E>,
585585
I::InferTy: Encodable<E>,
586586
I::PredicateKind: Encodable<E>,
587587
I::AllocId: Encodable<E>,
@@ -681,7 +681,7 @@ impl<I: Interner, D: TyDecoder<I = I>> Decodable<D> for TyKind<I>
681681
where
682682
I::ErrorGuaranteed: Decodable<D>,
683683
I::AdtDef: Decodable<D>,
684-
I::GenericArgsRef: Decodable<D>,
684+
I::GenericArgs: Decodable<D>,
685685
I::DefId: Decodable<D>,
686686
I::Ty: Decodable<D>,
687687
I::Const: Decodable<D>,
@@ -690,13 +690,13 @@ where
690690
I::Mutability: Decodable<D>,
691691
I::Movability: Decodable<D>,
692692
I::PolyFnSig: Decodable<D>,
693-
I::ListBinderExistentialPredicate: Decodable<D>,
694-
I::ListTy: Decodable<D>,
693+
I::BoundExistentialPredicates: Decodable<D>,
694+
I::Tys: Decodable<D>,
695695
I::AliasTy: Decodable<D>,
696696
I::ParamTy: Decodable<D>,
697697
I::AliasTy: Decodable<D>,
698698
I::BoundTy: Decodable<D>,
699-
I::PlaceholderType: Decodable<D>,
699+
I::PlaceholderTy: Decodable<D>,
700700
I::InferTy: Decodable<D>,
701701
I::PredicateKind: Decodable<D>,
702702
I::AllocId: Decodable<D>,
@@ -746,20 +746,20 @@ impl<CTX: HashStableContext, I: Interner> HashStable<CTX> for TyKind<I>
746746
where
747747
I::AdtDef: HashStable<CTX>,
748748
I::DefId: HashStable<CTX>,
749-
I::GenericArgsRef: HashStable<CTX>,
749+
I::GenericArgs: HashStable<CTX>,
750750
I::Ty: HashStable<CTX>,
751751
I::Const: HashStable<CTX>,
752752
I::TypeAndMut: HashStable<CTX>,
753753
I::PolyFnSig: HashStable<CTX>,
754-
I::ListBinderExistentialPredicate: HashStable<CTX>,
754+
I::BoundExistentialPredicates: HashStable<CTX>,
755755
I::Region: HashStable<CTX>,
756756
I::Movability: HashStable<CTX>,
757757
I::Mutability: HashStable<CTX>,
758-
I::ListTy: HashStable<CTX>,
758+
I::Tys: HashStable<CTX>,
759759
I::AliasTy: HashStable<CTX>,
760760
I::BoundTy: HashStable<CTX>,
761761
I::ParamTy: HashStable<CTX>,
762-
I::PlaceholderType: HashStable<CTX>,
762+
I::PlaceholderTy: HashStable<CTX>,
763763
I::InferTy: HashStable<CTX>,
764764
I::ErrorGuaranteed: HashStable<CTX>,
765765
{
@@ -1201,7 +1201,7 @@ pub enum RegionKind<I: Interner> {
12011201
ReStatic,
12021202

12031203
/// A region variable. Should not exist outside of type inference.
1204-
ReVar(I::RegionVid),
1204+
ReVar(I::InferRegion),
12051205

12061206
/// A placeholder region -- basically, the higher-ranked version of `ReFree`.
12071207
/// Should not exist outside of type inference.
@@ -1236,7 +1236,7 @@ where
12361236
I::EarlyBoundRegion: Copy,
12371237
I::BoundRegion: Copy,
12381238
I::FreeRegion: Copy,
1239-
I::RegionVid: Copy,
1239+
I::InferRegion: Copy,
12401240
I::PlaceholderRegion: Copy,
12411241
I::ErrorGuaranteed: Copy,
12421242
{
@@ -1376,7 +1376,7 @@ where
13761376
I::EarlyBoundRegion: Encodable<E>,
13771377
I::BoundRegion: Encodable<E>,
13781378
I::FreeRegion: Encodable<E>,
1379-
I::RegionVid: Encodable<E>,
1379+
I::InferRegion: Encodable<E>,
13801380
I::PlaceholderRegion: Encodable<E>,
13811381
{
13821382
fn encode(&self, e: &mut E) {
@@ -1411,7 +1411,7 @@ where
14111411
I::EarlyBoundRegion: Decodable<D>,
14121412
I::BoundRegion: Decodable<D>,
14131413
I::FreeRegion: Decodable<D>,
1414-
I::RegionVid: Decodable<D>,
1414+
I::InferRegion: Decodable<D>,
14151415
I::PlaceholderRegion: Decodable<D>,
14161416
I::ErrorGuaranteed: Decodable<D>,
14171417
{
@@ -1442,7 +1442,7 @@ where
14421442
I::EarlyBoundRegion: HashStable<CTX>,
14431443
I::BoundRegion: HashStable<CTX>,
14441444
I::FreeRegion: HashStable<CTX>,
1445-
I::RegionVid: HashStable<CTX>,
1445+
I::InferRegion: HashStable<CTX>,
14461446
I::PlaceholderRegion: HashStable<CTX>,
14471447
{
14481448
#[inline]

0 commit comments

Comments
 (0)