Some renaming nits for rustc_type_ir

This commit is contained in:
Michael Goulet 2023-10-18 23:29:28 +00:00
parent 8d20182999
commit 189e6a833e
4 changed files with 62 additions and 53 deletions

View File

@ -80,42 +80,40 @@ use std::ops::{Bound, Deref};
#[allow(rustc::usage_of_ty_tykind)] #[allow(rustc::usage_of_ty_tykind)]
impl<'tcx> Interner for TyCtxt<'tcx> { impl<'tcx> Interner for TyCtxt<'tcx> {
type AdtDef = ty::AdtDef<'tcx>;
type GenericArgsRef = ty::GenericArgsRef<'tcx>;
type GenericArg = ty::GenericArg<'tcx>;
type DefId = DefId; type DefId = DefId;
type AdtDef = ty::AdtDef<'tcx>;
type GenericArgs = ty::GenericArgsRef<'tcx>;
type GenericArg = ty::GenericArg<'tcx>;
type Binder<T> = Binder<'tcx, T>; type Binder<T> = Binder<'tcx, T>;
type Ty = Ty<'tcx>;
type Const = ty::Const<'tcx>;
type Region = Region<'tcx>;
type Predicate = Predicate<'tcx>; type Predicate = Predicate<'tcx>;
type PredicateKind = ty::PredicateKind<'tcx>;
type TypeAndMut = TypeAndMut<'tcx>; type TypeAndMut = TypeAndMut<'tcx>;
type Mutability = hir::Mutability; type Mutability = hir::Mutability;
type Movability = hir::Movability; type Movability = hir::Movability;
type PolyFnSig = PolyFnSig<'tcx>; type Ty = Ty<'tcx>;
type ListBinderExistentialPredicate = &'tcx List<PolyExistentialPredicate<'tcx>>; type Tys = &'tcx List<Ty<'tcx>>;
type ListTy = &'tcx List<Ty<'tcx>>;
type AliasTy = ty::AliasTy<'tcx>; type AliasTy = ty::AliasTy<'tcx>;
type ParamTy = ParamTy; type ParamTy = ParamTy;
type BoundTy = ty::BoundTy; type BoundTy = ty::BoundTy;
type PlaceholderType = ty::PlaceholderType; type PlaceholderTy = ty::PlaceholderType;
type InferTy = InferTy; type InferTy = InferTy;
type ErrorGuaranteed = ErrorGuaranteed; type ErrorGuaranteed = ErrorGuaranteed;
type PredicateKind = ty::PredicateKind<'tcx>; type BoundExistentialPredicates = &'tcx List<PolyExistentialPredicate<'tcx>>;
type PolyFnSig = PolyFnSig<'tcx>;
type AllocId = crate::mir::interpret::AllocId; type AllocId = crate::mir::interpret::AllocId;
type Const = ty::Const<'tcx>;
type InferConst = ty::InferConst<'tcx>; type InferConst = ty::InferConst<'tcx>;
type AliasConst = ty::UnevaluatedConst<'tcx>; type AliasConst = ty::UnevaluatedConst<'tcx>;
type PlaceholderConst = ty::PlaceholderConst<'tcx>;
type ParamConst = ty::ParamConst; type ParamConst = ty::ParamConst;
type BoundConst = ty::BoundVar; type BoundConst = ty::BoundVar;
type PlaceholderConst = ty::PlaceholderConst<'tcx>;
type ValueConst = ty::ValTree<'tcx>; type ValueConst = ty::ValTree<'tcx>;
type ExprConst = ty::Expr<'tcx>; type ExprConst = ty::Expr<'tcx>;
type Region = Region<'tcx>;
type EarlyBoundRegion = ty::EarlyBoundRegion; type EarlyBoundRegion = ty::EarlyBoundRegion;
type BoundRegion = ty::BoundRegion; type BoundRegion = ty::BoundRegion;
type FreeRegion = ty::FreeRegion; type FreeRegion = ty::FreeRegion;
type RegionVid = ty::RegionVid; type InferRegion = ty::RegionVid;
type PlaceholderRegion = ty::PlaceholderRegion; type PlaceholderRegion = ty::PlaceholderRegion;
fn ty_and_mut_to_parts( fn ty_and_mut_to_parts(

View File

@ -42,34 +42,43 @@ pub use ty_info::*;
pub trait HashStableContext {} pub trait HashStableContext {}
pub trait Interner: Sized { pub trait Interner: Sized {
type DefId: Clone + Debug + Hash + Ord;
type AdtDef: Clone + Debug + Hash + Ord; type AdtDef: Clone + Debug + Hash + Ord;
type GenericArgsRef: Clone
type GenericArgs: Clone
+ DebugWithInfcx<Self> + DebugWithInfcx<Self>
+ Hash + Hash
+ Ord + Ord
+ IntoIterator<Item = Self::GenericArg>; + IntoIterator<Item = Self::GenericArg>;
type GenericArg: Clone + DebugWithInfcx<Self> + Hash + Ord; type GenericArg: Clone + DebugWithInfcx<Self> + Hash + Ord;
type DefId: Clone + Debug + Hash + Ord;
type Binder<T>; type Binder<T>;
type Ty: Clone + DebugWithInfcx<Self> + Hash + Ord;
type Const: Clone + DebugWithInfcx<Self> + Hash + Ord; // Predicates
type Region: Clone + DebugWithInfcx<Self> + Hash + Ord;
type Predicate; type Predicate;
type PredicateKind: Clone + Debug + Hash + PartialEq + Eq;
type TypeAndMut: Clone + Debug + Hash + Ord; type TypeAndMut: Clone + Debug + Hash + Ord;
type Mutability: Clone + Debug + Hash + Ord; type Mutability: Clone + Debug + Hash + Ord;
type Movability: Clone + Debug + Hash + Ord; type Movability: Clone + Debug + Hash + Ord;
type PolyFnSig: Clone + DebugWithInfcx<Self> + Hash + Ord;
type ListBinderExistentialPredicate: Clone + DebugWithInfcx<Self> + Hash + Ord; // Kinds of tys
type ListTy: Clone + Debug + Hash + Ord + IntoIterator<Item = Self::Ty>; type Ty: Clone + DebugWithInfcx<Self> + Hash + Ord;
type Tys: Clone + Debug + Hash + Ord + IntoIterator<Item = Self::Ty>;
type AliasTy: Clone + DebugWithInfcx<Self> + Hash + Ord; type AliasTy: Clone + DebugWithInfcx<Self> + Hash + Ord;
type ParamTy: Clone + Debug + Hash + Ord; type ParamTy: Clone + Debug + Hash + Ord;
type BoundTy: Clone + Debug + Hash + Ord; type BoundTy: Clone + Debug + Hash + Ord;
type PlaceholderType: Clone + Debug + Hash + Ord; type PlaceholderTy: Clone + Debug + Hash + Ord;
type InferTy: Clone + DebugWithInfcx<Self> + Hash + Ord; type InferTy: Clone + DebugWithInfcx<Self> + Hash + Ord;
// Things stored inside of tys
type ErrorGuaranteed: Clone + Debug + Hash + Ord; type ErrorGuaranteed: Clone + Debug + Hash + Ord;
type PredicateKind: Clone + Debug + Hash + PartialEq + Eq; type BoundExistentialPredicates: Clone + DebugWithInfcx<Self> + Hash + Ord;
type PolyFnSig: Clone + DebugWithInfcx<Self> + Hash + Ord;
type AllocId: Clone + Debug + Hash + Ord; type AllocId: Clone + Debug + Hash + Ord;
// Kinds of consts
type Const: Clone + DebugWithInfcx<Self> + Hash + Ord;
type InferConst: Clone + DebugWithInfcx<Self> + Hash + Ord; type InferConst: Clone + DebugWithInfcx<Self> + Hash + Ord;
type AliasConst: Clone + DebugWithInfcx<Self> + Hash + Ord; type AliasConst: Clone + DebugWithInfcx<Self> + Hash + Ord;
type PlaceholderConst: Clone + Debug + Hash + Ord; type PlaceholderConst: Clone + Debug + Hash + Ord;
@ -78,10 +87,12 @@ pub trait Interner: Sized {
type ValueConst: Clone + Debug + Hash + Ord; type ValueConst: Clone + Debug + Hash + Ord;
type ExprConst: Clone + DebugWithInfcx<Self> + Hash + Ord; type ExprConst: Clone + DebugWithInfcx<Self> + Hash + Ord;
// Kinds of regions
type Region: Clone + DebugWithInfcx<Self> + Hash + Ord;
type EarlyBoundRegion: Clone + Debug + Hash + Ord; type EarlyBoundRegion: Clone + Debug + Hash + Ord;
type BoundRegion: Clone + Debug + Hash + Ord; type BoundRegion: Clone + Debug + Hash + Ord;
type FreeRegion: Clone + Debug + Hash + Ord; type FreeRegion: Clone + Debug + Hash + Ord;
type RegionVid: Clone + DebugWithInfcx<Self> + Hash + Ord; type InferRegion: Clone + DebugWithInfcx<Self> + Hash + Ord;
type PlaceholderRegion: Clone + Debug + Hash + Ord; type PlaceholderRegion: Clone + Debug + Hash + Ord;
fn ty_and_mut_to_parts(ty_and_mut: Self::TypeAndMut) -> (Self::Ty, Self::Mutability); fn ty_and_mut_to_parts(ty_and_mut: Self::TypeAndMut) -> (Self::Ty, Self::Mutability);

View File

@ -208,7 +208,7 @@ impl<I: Interner, T: TypeVisitable<I>, Ix: Idx> TypeVisitable<I> for IndexVec<Ix
pub trait InferCtxtLike<I: Interner> { pub trait InferCtxtLike<I: Interner> {
fn universe_of_ty(&self, ty: I::InferTy) -> Option<UniverseIndex>; fn universe_of_ty(&self, ty: I::InferTy) -> Option<UniverseIndex>;
fn universe_of_lt(&self, lt: I::RegionVid) -> Option<UniverseIndex>; fn universe_of_lt(&self, lt: I::InferRegion) -> Option<UniverseIndex>;
fn universe_of_ct(&self, ct: I::InferConst) -> Option<UniverseIndex>; fn universe_of_ct(&self, ct: I::InferConst) -> Option<UniverseIndex>;
} }
@ -219,7 +219,7 @@ impl<I: Interner> InferCtxtLike<I> for core::convert::Infallible {
fn universe_of_ct(&self, _ct: <I as Interner>::InferConst) -> Option<UniverseIndex> { fn universe_of_ct(&self, _ct: <I as Interner>::InferConst) -> Option<UniverseIndex> {
match *self {} match *self {}
} }
fn universe_of_lt(&self, _lt: <I as Interner>::RegionVid) -> Option<UniverseIndex> { fn universe_of_lt(&self, _lt: <I as Interner>::InferRegion) -> Option<UniverseIndex> {
match *self {} match *self {}
} }
} }

View File

@ -79,7 +79,7 @@ pub enum TyKind<I: Interner> {
/// ///
/// Note that generic parameters in fields only get lazily substituted /// Note that generic parameters in fields only get lazily substituted
/// by using something like `adt_def.all_fields().map(|field| field.ty(tcx, args))`. /// by using something like `adt_def.all_fields().map(|field| field.ty(tcx, args))`.
Adt(I::AdtDef, I::GenericArgsRef), Adt(I::AdtDef, I::GenericArgs),
/// An unsized FFI type that is opaque to Rust. Written as `extern type T`. /// An unsized FFI type that is opaque to Rust. Written as `extern type T`.
Foreign(I::DefId), Foreign(I::DefId),
@ -111,7 +111,7 @@ pub enum TyKind<I: Interner> {
/// fn foo() -> i32 { 1 } /// fn foo() -> i32 { 1 }
/// let bar = foo; // bar: fn() -> i32 {foo} /// let bar = foo; // bar: fn() -> i32 {foo}
/// ``` /// ```
FnDef(I::DefId, I::GenericArgsRef), FnDef(I::DefId, I::GenericArgs),
/// A pointer to a function. Written as `fn() -> i32`. /// A pointer to a function. Written as `fn() -> i32`.
/// ///
@ -127,21 +127,21 @@ pub enum TyKind<I: Interner> {
FnPtr(I::PolyFnSig), FnPtr(I::PolyFnSig),
/// A trait object. Written as `dyn for<'b> Trait<'b, Assoc = u32> + Send + 'a`. /// A trait object. Written as `dyn for<'b> Trait<'b, Assoc = u32> + Send + 'a`.
Dynamic(I::ListBinderExistentialPredicate, I::Region, DynKind), Dynamic(I::BoundExistentialPredicates, I::Region, DynKind),
/// The anonymous type of a closure. Used to represent the type of `|a| a`. /// The anonymous type of a closure. Used to represent the type of `|a| a`.
/// ///
/// Closure args contain both the - potentially substituted - generic parameters /// Closure args contain both the - potentially substituted - generic parameters
/// of its parent and some synthetic parameters. See the documentation for /// of its parent and some synthetic parameters. See the documentation for
/// `ClosureArgs` for more details. /// `ClosureArgs` for more details.
Closure(I::DefId, I::GenericArgsRef), Closure(I::DefId, I::GenericArgs),
/// The anonymous type of a generator. Used to represent the type of /// The anonymous type of a generator. Used to represent the type of
/// `|a| yield a`. /// `|a| yield a`.
/// ///
/// For more info about generator args, visit the documentation for /// For more info about generator args, visit the documentation for
/// `GeneratorArgs`. /// `GeneratorArgs`.
Generator(I::DefId, I::GenericArgsRef, I::Movability), Generator(I::DefId, I::GenericArgs, I::Movability),
/// A type representing the types stored inside a generator. /// A type representing the types stored inside a generator.
/// This should only appear as part of the `GeneratorArgs`. /// This should only appear as part of the `GeneratorArgs`.
@ -167,13 +167,13 @@ pub enum TyKind<I: Interner> {
/// } /// }
/// # ; /// # ;
/// ``` /// ```
GeneratorWitness(I::DefId, I::GenericArgsRef), GeneratorWitness(I::DefId, I::GenericArgs),
/// The never type `!`. /// The never type `!`.
Never, Never,
/// A tuple type. For example, `(i32, bool)`. /// A tuple type. For example, `(i32, bool)`.
Tuple(I::ListTy), Tuple(I::Tys),
/// A projection, opaque type, weak type alias, or inherent associated type. /// A projection, opaque type, weak type alias, or inherent associated type.
/// All of these types are represented as pairs of def-id and args, and can /// All of these types are represented as pairs of def-id and args, and can
@ -209,7 +209,7 @@ pub enum TyKind<I: Interner> {
/// to the bound variable's index from the binder from which it was instantiated), /// to the bound variable's index from the binder from which it was instantiated),
/// and `U` is the universe index in which it is instantiated, or totally omitted /// and `U` is the universe index in which it is instantiated, or totally omitted
/// if the universe index is zero. /// if the universe index is zero.
Placeholder(I::PlaceholderType), Placeholder(I::PlaceholderTy),
/// A type variable used during type checking. /// A type variable used during type checking.
/// ///
@ -567,7 +567,7 @@ impl<I: Interner, E: TyEncoder> Encodable<E> for TyKind<I>
where where
I::ErrorGuaranteed: Encodable<E>, I::ErrorGuaranteed: Encodable<E>,
I::AdtDef: Encodable<E>, I::AdtDef: Encodable<E>,
I::GenericArgsRef: Encodable<E>, I::GenericArgs: Encodable<E>,
I::DefId: Encodable<E>, I::DefId: Encodable<E>,
I::Ty: Encodable<E>, I::Ty: Encodable<E>,
I::Const: Encodable<E>, I::Const: Encodable<E>,
@ -576,12 +576,12 @@ where
I::Mutability: Encodable<E>, I::Mutability: Encodable<E>,
I::Movability: Encodable<E>, I::Movability: Encodable<E>,
I::PolyFnSig: Encodable<E>, I::PolyFnSig: Encodable<E>,
I::ListBinderExistentialPredicate: Encodable<E>, I::BoundExistentialPredicates: Encodable<E>,
I::ListTy: Encodable<E>, I::Tys: Encodable<E>,
I::AliasTy: Encodable<E>, I::AliasTy: Encodable<E>,
I::ParamTy: Encodable<E>, I::ParamTy: Encodable<E>,
I::BoundTy: Encodable<E>, I::BoundTy: Encodable<E>,
I::PlaceholderType: Encodable<E>, I::PlaceholderTy: Encodable<E>,
I::InferTy: Encodable<E>, I::InferTy: Encodable<E>,
I::PredicateKind: Encodable<E>, I::PredicateKind: Encodable<E>,
I::AllocId: Encodable<E>, I::AllocId: Encodable<E>,
@ -681,7 +681,7 @@ impl<I: Interner, D: TyDecoder<I = I>> Decodable<D> for TyKind<I>
where where
I::ErrorGuaranteed: Decodable<D>, I::ErrorGuaranteed: Decodable<D>,
I::AdtDef: Decodable<D>, I::AdtDef: Decodable<D>,
I::GenericArgsRef: Decodable<D>, I::GenericArgs: Decodable<D>,
I::DefId: Decodable<D>, I::DefId: Decodable<D>,
I::Ty: Decodable<D>, I::Ty: Decodable<D>,
I::Const: Decodable<D>, I::Const: Decodable<D>,
@ -690,13 +690,13 @@ where
I::Mutability: Decodable<D>, I::Mutability: Decodable<D>,
I::Movability: Decodable<D>, I::Movability: Decodable<D>,
I::PolyFnSig: Decodable<D>, I::PolyFnSig: Decodable<D>,
I::ListBinderExistentialPredicate: Decodable<D>, I::BoundExistentialPredicates: Decodable<D>,
I::ListTy: Decodable<D>, I::Tys: Decodable<D>,
I::AliasTy: Decodable<D>, I::AliasTy: Decodable<D>,
I::ParamTy: Decodable<D>, I::ParamTy: Decodable<D>,
I::AliasTy: Decodable<D>, I::AliasTy: Decodable<D>,
I::BoundTy: Decodable<D>, I::BoundTy: Decodable<D>,
I::PlaceholderType: Decodable<D>, I::PlaceholderTy: Decodable<D>,
I::InferTy: Decodable<D>, I::InferTy: Decodable<D>,
I::PredicateKind: Decodable<D>, I::PredicateKind: Decodable<D>,
I::AllocId: Decodable<D>, I::AllocId: Decodable<D>,
@ -746,20 +746,20 @@ impl<CTX: HashStableContext, I: Interner> HashStable<CTX> for TyKind<I>
where where
I::AdtDef: HashStable<CTX>, I::AdtDef: HashStable<CTX>,
I::DefId: HashStable<CTX>, I::DefId: HashStable<CTX>,
I::GenericArgsRef: HashStable<CTX>, I::GenericArgs: HashStable<CTX>,
I::Ty: HashStable<CTX>, I::Ty: HashStable<CTX>,
I::Const: HashStable<CTX>, I::Const: HashStable<CTX>,
I::TypeAndMut: HashStable<CTX>, I::TypeAndMut: HashStable<CTX>,
I::PolyFnSig: HashStable<CTX>, I::PolyFnSig: HashStable<CTX>,
I::ListBinderExistentialPredicate: HashStable<CTX>, I::BoundExistentialPredicates: HashStable<CTX>,
I::Region: HashStable<CTX>, I::Region: HashStable<CTX>,
I::Movability: HashStable<CTX>, I::Movability: HashStable<CTX>,
I::Mutability: HashStable<CTX>, I::Mutability: HashStable<CTX>,
I::ListTy: HashStable<CTX>, I::Tys: HashStable<CTX>,
I::AliasTy: HashStable<CTX>, I::AliasTy: HashStable<CTX>,
I::BoundTy: HashStable<CTX>, I::BoundTy: HashStable<CTX>,
I::ParamTy: HashStable<CTX>, I::ParamTy: HashStable<CTX>,
I::PlaceholderType: HashStable<CTX>, I::PlaceholderTy: HashStable<CTX>,
I::InferTy: HashStable<CTX>, I::InferTy: HashStable<CTX>,
I::ErrorGuaranteed: HashStable<CTX>, I::ErrorGuaranteed: HashStable<CTX>,
{ {
@ -1201,7 +1201,7 @@ pub enum RegionKind<I: Interner> {
ReStatic, ReStatic,
/// A region variable. Should not exist outside of type inference. /// A region variable. Should not exist outside of type inference.
ReVar(I::RegionVid), ReVar(I::InferRegion),
/// A placeholder region -- basically, the higher-ranked version of `ReFree`. /// A placeholder region -- basically, the higher-ranked version of `ReFree`.
/// Should not exist outside of type inference. /// Should not exist outside of type inference.
@ -1236,7 +1236,7 @@ where
I::EarlyBoundRegion: Copy, I::EarlyBoundRegion: Copy,
I::BoundRegion: Copy, I::BoundRegion: Copy,
I::FreeRegion: Copy, I::FreeRegion: Copy,
I::RegionVid: Copy, I::InferRegion: Copy,
I::PlaceholderRegion: Copy, I::PlaceholderRegion: Copy,
I::ErrorGuaranteed: Copy, I::ErrorGuaranteed: Copy,
{ {
@ -1376,7 +1376,7 @@ where
I::EarlyBoundRegion: Encodable<E>, I::EarlyBoundRegion: Encodable<E>,
I::BoundRegion: Encodable<E>, I::BoundRegion: Encodable<E>,
I::FreeRegion: Encodable<E>, I::FreeRegion: Encodable<E>,
I::RegionVid: Encodable<E>, I::InferRegion: Encodable<E>,
I::PlaceholderRegion: Encodable<E>, I::PlaceholderRegion: Encodable<E>,
{ {
fn encode(&self, e: &mut E) { fn encode(&self, e: &mut E) {
@ -1411,7 +1411,7 @@ where
I::EarlyBoundRegion: Decodable<D>, I::EarlyBoundRegion: Decodable<D>,
I::BoundRegion: Decodable<D>, I::BoundRegion: Decodable<D>,
I::FreeRegion: Decodable<D>, I::FreeRegion: Decodable<D>,
I::RegionVid: Decodable<D>, I::InferRegion: Decodable<D>,
I::PlaceholderRegion: Decodable<D>, I::PlaceholderRegion: Decodable<D>,
I::ErrorGuaranteed: Decodable<D>, I::ErrorGuaranteed: Decodable<D>,
{ {
@ -1442,7 +1442,7 @@ where
I::EarlyBoundRegion: HashStable<CTX>, I::EarlyBoundRegion: HashStable<CTX>,
I::BoundRegion: HashStable<CTX>, I::BoundRegion: HashStable<CTX>,
I::FreeRegion: HashStable<CTX>, I::FreeRegion: HashStable<CTX>,
I::RegionVid: HashStable<CTX>, I::InferRegion: HashStable<CTX>,
I::PlaceholderRegion: HashStable<CTX>, I::PlaceholderRegion: HashStable<CTX>,
{ {
#[inline] #[inline]