From 8d20182999a2baf711e37da276c1a4b2831dcc12 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 18 Oct 2023 23:09:17 +0000 Subject: [PATCH 1/2] Remove unused variant BinderListTy --- compiler/rustc_middle/src/ty/context.rs | 1 - compiler/rustc_type_ir/src/lib.rs | 1 - compiler/rustc_type_ir/src/sty.rs | 3 --- 3 files changed, 5 deletions(-) diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 05706e331f3a7..5030474d96b22 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -94,7 +94,6 @@ impl<'tcx> Interner for TyCtxt<'tcx> { type Movability = hir::Movability; type PolyFnSig = PolyFnSig<'tcx>; type ListBinderExistentialPredicate = &'tcx List>; - type BinderListTy = Binder<'tcx, &'tcx List>>; type ListTy = &'tcx List>; type AliasTy = ty::AliasTy<'tcx>; type ParamTy = ParamTy; diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index 9f8d9f02ec24c..51b3007723b29 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -60,7 +60,6 @@ pub trait Interner: Sized { type Movability: Clone + Debug + Hash + Ord; type PolyFnSig: Clone + DebugWithInfcx + Hash + Ord; type ListBinderExistentialPredicate: Clone + DebugWithInfcx + Hash + Ord; - type BinderListTy: Clone + DebugWithInfcx + Hash + Ord; type ListTy: Clone + Debug + Hash + Ord + IntoIterator; type AliasTy: Clone + DebugWithInfcx + Hash + Ord; type ParamTy: Clone + Debug + Hash + Ord; diff --git a/compiler/rustc_type_ir/src/sty.rs b/compiler/rustc_type_ir/src/sty.rs index 091b51440a6e1..5ff17a48e756b 100644 --- a/compiler/rustc_type_ir/src/sty.rs +++ b/compiler/rustc_type_ir/src/sty.rs @@ -577,7 +577,6 @@ where I::Movability: Encodable, I::PolyFnSig: Encodable, I::ListBinderExistentialPredicate: Encodable, - I::BinderListTy: Encodable, I::ListTy: Encodable, I::AliasTy: Encodable, I::ParamTy: Encodable, @@ -692,7 +691,6 @@ where I::Movability: Decodable, I::PolyFnSig: Decodable, I::ListBinderExistentialPredicate: Decodable, - I::BinderListTy: Decodable, I::ListTy: Decodable, I::AliasTy: Decodable, I::ParamTy: Decodable, @@ -757,7 +755,6 @@ where I::Region: HashStable, I::Movability: HashStable, I::Mutability: HashStable, - I::BinderListTy: HashStable, I::ListTy: HashStable, I::AliasTy: HashStable, I::BoundTy: HashStable, From 189e6a833eaa370ce2c66bd451f536e8ee7e7f14 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 18 Oct 2023 23:29:28 +0000 Subject: [PATCH 2/2] Some renaming nits for rustc_type_ir --- compiler/rustc_middle/src/ty/context.rs | 26 +++++----- compiler/rustc_type_ir/src/lib.rs | 33 ++++++++---- .../rustc_type_ir/src/structural_impls.rs | 4 +- compiler/rustc_type_ir/src/sty.rs | 50 +++++++++---------- 4 files changed, 61 insertions(+), 52 deletions(-) diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 5030474d96b22..82c7f8ab48673 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -80,42 +80,40 @@ use std::ops::{Bound, Deref}; #[allow(rustc::usage_of_ty_tykind)] impl<'tcx> Interner for TyCtxt<'tcx> { + type DefId = DefId; type AdtDef = ty::AdtDef<'tcx>; - type GenericArgsRef = ty::GenericArgsRef<'tcx>; + type GenericArgs = ty::GenericArgsRef<'tcx>; type GenericArg = ty::GenericArg<'tcx>; - type DefId = DefId; type Binder = Binder<'tcx, T>; - type Ty = Ty<'tcx>; - type Const = ty::Const<'tcx>; - type Region = Region<'tcx>; type Predicate = Predicate<'tcx>; + type PredicateKind = ty::PredicateKind<'tcx>; type TypeAndMut = TypeAndMut<'tcx>; type Mutability = hir::Mutability; type Movability = hir::Movability; - type PolyFnSig = PolyFnSig<'tcx>; - type ListBinderExistentialPredicate = &'tcx List>; - type ListTy = &'tcx List>; + type Ty = Ty<'tcx>; + type Tys = &'tcx List>; type AliasTy = ty::AliasTy<'tcx>; type ParamTy = ParamTy; type BoundTy = ty::BoundTy; - type PlaceholderType = ty::PlaceholderType; + type PlaceholderTy = ty::PlaceholderType; type InferTy = InferTy; type ErrorGuaranteed = ErrorGuaranteed; - type PredicateKind = ty::PredicateKind<'tcx>; + type BoundExistentialPredicates = &'tcx List>; + type PolyFnSig = PolyFnSig<'tcx>; type AllocId = crate::mir::interpret::AllocId; - + type Const = ty::Const<'tcx>; type InferConst = ty::InferConst<'tcx>; type AliasConst = ty::UnevaluatedConst<'tcx>; + type PlaceholderConst = ty::PlaceholderConst<'tcx>; type ParamConst = ty::ParamConst; type BoundConst = ty::BoundVar; - type PlaceholderConst = ty::PlaceholderConst<'tcx>; type ValueConst = ty::ValTree<'tcx>; type ExprConst = ty::Expr<'tcx>; - + type Region = Region<'tcx>; type EarlyBoundRegion = ty::EarlyBoundRegion; type BoundRegion = ty::BoundRegion; type FreeRegion = ty::FreeRegion; - type RegionVid = ty::RegionVid; + type InferRegion = ty::RegionVid; type PlaceholderRegion = ty::PlaceholderRegion; fn ty_and_mut_to_parts( diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index 51b3007723b29..6b1f0bae91ad4 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -42,34 +42,43 @@ pub use ty_info::*; pub trait HashStableContext {} pub trait Interner: Sized { + type DefId: Clone + Debug + Hash + Ord; type AdtDef: Clone + Debug + Hash + Ord; - type GenericArgsRef: Clone + + type GenericArgs: Clone + DebugWithInfcx + Hash + Ord + IntoIterator; type GenericArg: Clone + DebugWithInfcx + Hash + Ord; - type DefId: Clone + Debug + Hash + Ord; + type Binder; - type Ty: Clone + DebugWithInfcx + Hash + Ord; - type Const: Clone + DebugWithInfcx + Hash + Ord; - type Region: Clone + DebugWithInfcx + Hash + Ord; + + // Predicates type Predicate; + type PredicateKind: Clone + Debug + Hash + PartialEq + Eq; + type TypeAndMut: Clone + Debug + Hash + Ord; type Mutability: Clone + Debug + Hash + Ord; type Movability: Clone + Debug + Hash + Ord; - type PolyFnSig: Clone + DebugWithInfcx + Hash + Ord; - type ListBinderExistentialPredicate: Clone + DebugWithInfcx + Hash + Ord; - type ListTy: Clone + Debug + Hash + Ord + IntoIterator; + + // Kinds of tys + type Ty: Clone + DebugWithInfcx + Hash + Ord; + type Tys: Clone + Debug + Hash + Ord + IntoIterator; type AliasTy: Clone + DebugWithInfcx + Hash + Ord; type ParamTy: 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 + Hash + Ord; + + // Things stored inside of tys type ErrorGuaranteed: Clone + Debug + Hash + Ord; - type PredicateKind: Clone + Debug + Hash + PartialEq + Eq; + type BoundExistentialPredicates: Clone + DebugWithInfcx + Hash + Ord; + type PolyFnSig: Clone + DebugWithInfcx + Hash + Ord; type AllocId: Clone + Debug + Hash + Ord; + // Kinds of consts + type Const: Clone + DebugWithInfcx + Hash + Ord; type InferConst: Clone + DebugWithInfcx + Hash + Ord; type AliasConst: Clone + DebugWithInfcx + Hash + Ord; type PlaceholderConst: Clone + Debug + Hash + Ord; @@ -78,10 +87,12 @@ pub trait Interner: Sized { type ValueConst: Clone + Debug + Hash + Ord; type ExprConst: Clone + DebugWithInfcx + Hash + Ord; + // Kinds of regions + type Region: Clone + DebugWithInfcx + Hash + Ord; type EarlyBoundRegion: Clone + Debug + Hash + Ord; type BoundRegion: Clone + Debug + Hash + Ord; type FreeRegion: Clone + Debug + Hash + Ord; - type RegionVid: Clone + DebugWithInfcx + Hash + Ord; + type InferRegion: Clone + DebugWithInfcx + Hash + Ord; type PlaceholderRegion: Clone + Debug + Hash + Ord; fn ty_and_mut_to_parts(ty_and_mut: Self::TypeAndMut) -> (Self::Ty, Self::Mutability); diff --git a/compiler/rustc_type_ir/src/structural_impls.rs b/compiler/rustc_type_ir/src/structural_impls.rs index 08af96ea15f0f..93b3674b51a56 100644 --- a/compiler/rustc_type_ir/src/structural_impls.rs +++ b/compiler/rustc_type_ir/src/structural_impls.rs @@ -208,7 +208,7 @@ impl, Ix: Idx> TypeVisitable for IndexVec { fn universe_of_ty(&self, ty: I::InferTy) -> Option; - fn universe_of_lt(&self, lt: I::RegionVid) -> Option; + fn universe_of_lt(&self, lt: I::InferRegion) -> Option; fn universe_of_ct(&self, ct: I::InferConst) -> Option; } @@ -219,7 +219,7 @@ impl InferCtxtLike for core::convert::Infallible { fn universe_of_ct(&self, _ct: ::InferConst) -> Option { match *self {} } - fn universe_of_lt(&self, _lt: ::RegionVid) -> Option { + fn universe_of_lt(&self, _lt: ::InferRegion) -> Option { match *self {} } } diff --git a/compiler/rustc_type_ir/src/sty.rs b/compiler/rustc_type_ir/src/sty.rs index 5ff17a48e756b..991b8e1589bc0 100644 --- a/compiler/rustc_type_ir/src/sty.rs +++ b/compiler/rustc_type_ir/src/sty.rs @@ -79,7 +79,7 @@ pub enum TyKind { /// /// Note that generic parameters in fields only get lazily substituted /// 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`. Foreign(I::DefId), @@ -111,7 +111,7 @@ pub enum TyKind { /// fn foo() -> i32 { 1 } /// 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`. /// @@ -127,21 +127,21 @@ pub enum TyKind { FnPtr(I::PolyFnSig), /// 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`. /// /// Closure args contain both the - potentially substituted - generic parameters /// of its parent and some synthetic parameters. See the documentation for /// `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 /// `|a| yield a`. /// /// For more info about generator args, visit the documentation for /// `GeneratorArgs`. - Generator(I::DefId, I::GenericArgsRef, I::Movability), + Generator(I::DefId, I::GenericArgs, I::Movability), /// A type representing the types stored inside a generator. /// This should only appear as part of the `GeneratorArgs`. @@ -167,13 +167,13 @@ pub enum TyKind { /// } /// # ; /// ``` - GeneratorWitness(I::DefId, I::GenericArgsRef), + GeneratorWitness(I::DefId, I::GenericArgs), /// The never type `!`. Never, /// A tuple type. For example, `(i32, bool)`. - Tuple(I::ListTy), + Tuple(I::Tys), /// 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 @@ -209,7 +209,7 @@ pub enum TyKind { /// 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 /// if the universe index is zero. - Placeholder(I::PlaceholderType), + Placeholder(I::PlaceholderTy), /// A type variable used during type checking. /// @@ -567,7 +567,7 @@ impl Encodable for TyKind where I::ErrorGuaranteed: Encodable, I::AdtDef: Encodable, - I::GenericArgsRef: Encodable, + I::GenericArgs: Encodable, I::DefId: Encodable, I::Ty: Encodable, I::Const: Encodable, @@ -576,12 +576,12 @@ where I::Mutability: Encodable, I::Movability: Encodable, I::PolyFnSig: Encodable, - I::ListBinderExistentialPredicate: Encodable, - I::ListTy: Encodable, + I::BoundExistentialPredicates: Encodable, + I::Tys: Encodable, I::AliasTy: Encodable, I::ParamTy: Encodable, I::BoundTy: Encodable, - I::PlaceholderType: Encodable, + I::PlaceholderTy: Encodable, I::InferTy: Encodable, I::PredicateKind: Encodable, I::AllocId: Encodable, @@ -681,7 +681,7 @@ impl> Decodable for TyKind where I::ErrorGuaranteed: Decodable, I::AdtDef: Decodable, - I::GenericArgsRef: Decodable, + I::GenericArgs: Decodable, I::DefId: Decodable, I::Ty: Decodable, I::Const: Decodable, @@ -690,13 +690,13 @@ where I::Mutability: Decodable, I::Movability: Decodable, I::PolyFnSig: Decodable, - I::ListBinderExistentialPredicate: Decodable, - I::ListTy: Decodable, + I::BoundExistentialPredicates: Decodable, + I::Tys: Decodable, I::AliasTy: Decodable, I::ParamTy: Decodable, I::AliasTy: Decodable, I::BoundTy: Decodable, - I::PlaceholderType: Decodable, + I::PlaceholderTy: Decodable, I::InferTy: Decodable, I::PredicateKind: Decodable, I::AllocId: Decodable, @@ -746,20 +746,20 @@ impl HashStable for TyKind where I::AdtDef: HashStable, I::DefId: HashStable, - I::GenericArgsRef: HashStable, + I::GenericArgs: HashStable, I::Ty: HashStable, I::Const: HashStable, I::TypeAndMut: HashStable, I::PolyFnSig: HashStable, - I::ListBinderExistentialPredicate: HashStable, + I::BoundExistentialPredicates: HashStable, I::Region: HashStable, I::Movability: HashStable, I::Mutability: HashStable, - I::ListTy: HashStable, + I::Tys: HashStable, I::AliasTy: HashStable, I::BoundTy: HashStable, I::ParamTy: HashStable, - I::PlaceholderType: HashStable, + I::PlaceholderTy: HashStable, I::InferTy: HashStable, I::ErrorGuaranteed: HashStable, { @@ -1201,7 +1201,7 @@ pub enum RegionKind { ReStatic, /// 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`. /// Should not exist outside of type inference. @@ -1236,7 +1236,7 @@ where I::EarlyBoundRegion: Copy, I::BoundRegion: Copy, I::FreeRegion: Copy, - I::RegionVid: Copy, + I::InferRegion: Copy, I::PlaceholderRegion: Copy, I::ErrorGuaranteed: Copy, { @@ -1376,7 +1376,7 @@ where I::EarlyBoundRegion: Encodable, I::BoundRegion: Encodable, I::FreeRegion: Encodable, - I::RegionVid: Encodable, + I::InferRegion: Encodable, I::PlaceholderRegion: Encodable, { fn encode(&self, e: &mut E) { @@ -1411,7 +1411,7 @@ where I::EarlyBoundRegion: Decodable, I::BoundRegion: Decodable, I::FreeRegion: Decodable, - I::RegionVid: Decodable, + I::InferRegion: Decodable, I::PlaceholderRegion: Decodable, I::ErrorGuaranteed: Decodable, { @@ -1442,7 +1442,7 @@ where I::EarlyBoundRegion: HashStable, I::BoundRegion: HashStable, I::FreeRegion: HashStable, - I::RegionVid: HashStable, + I::InferRegion: HashStable, I::PlaceholderRegion: HashStable, { #[inline]