1
Fork 0
- Take more things by self, not &self
- Clone more things
- Rework namespacing so we can use `ty::` in the canonicalizer
This commit is contained in:
Michael Goulet 2023-12-05 18:10:23 +00:00
parent cb41509601
commit 1f5895b3e3
11 changed files with 205 additions and 229 deletions

View file

@ -29,14 +29,14 @@ pub struct Const<'tcx>(pub(super) Interned<'tcx, WithCachedTypeInfo<ConstData<'t
impl<'tcx> IntoKind for Const<'tcx> {
type Kind = ConstKind<'tcx>;
fn kind(&self) -> ConstKind<'tcx> {
(*self).kind().clone()
fn kind(self) -> ConstKind<'tcx> {
self.kind().clone()
}
}
impl<'tcx> ConstTy<TyCtxt<'tcx>> for Const<'tcx> {
fn ty(&self) -> Ty<'tcx> {
(*self).ty()
fn ty(self) -> Ty<'tcx> {
self.ty()
}
}

View file

@ -132,40 +132,29 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
(ty, mutbl)
}
fn mk_canonical_var_infos(
&self,
infos: &[rustc_type_ir::CanonicalVarInfo<Self>],
) -> Self::CanonicalVars {
(*self).mk_canonical_var_infos(infos)
fn mk_canonical_var_infos(self, infos: &[ty::CanonicalVarInfo<Self>]) -> Self::CanonicalVars {
self.mk_canonical_var_infos(infos)
}
fn mk_bound_ty(
&self,
debruijn: rustc_type_ir::DebruijnIndex,
var: rustc_type_ir::BoundVar,
) -> Self::Ty {
Ty::new_bound(*self, debruijn, ty::BoundTy { var, kind: ty::BoundTyKind::Anon })
fn mk_bound_ty(self, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self::Ty {
Ty::new_bound(self, debruijn, ty::BoundTy { var, kind: ty::BoundTyKind::Anon })
}
fn mk_bound_region(
&self,
debruijn: rustc_type_ir::DebruijnIndex,
var: rustc_type_ir::BoundVar,
) -> Self::Region {
fn mk_bound_region(self, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self::Region {
Region::new_bound(
*self,
self,
debruijn,
ty::BoundRegion { var, kind: ty::BoundRegionKind::BrAnon },
)
}
fn mk_bound_const(
&self,
debruijn: rustc_type_ir::DebruijnIndex,
var: rustc_type_ir::BoundVar,
self,
debruijn: ty::DebruijnIndex,
var: ty::BoundVar,
ty: Self::Ty,
) -> Self::Const {
Const::new_bound(*self, debruijn, var, ty)
Const::new_bound(self, debruijn, var, ty)
}
}

View file

@ -65,15 +65,10 @@ use std::ops::ControlFlow;
use std::{fmt, str};
pub use crate::ty::diagnostics::*;
pub use rustc_type_ir::AliasKind::*;
pub use rustc_type_ir::ConstKind::{
Bound as BoundCt, Error as ErrorCt, Expr as ExprCt, Infer as InferCt, Param as ParamCt,
Placeholder as PlaceholderCt, Unevaluated, Value,
};
pub use rustc_type_ir::DynKind::*;
pub use rustc_type_ir::InferTy::*;
pub use rustc_type_ir::RegionKind::*;
pub use rustc_type_ir::TyKind::*;
pub use rustc_type_ir::*;
pub use self::binding::BindingMode;
@ -477,8 +472,8 @@ pub struct Ty<'tcx>(Interned<'tcx, WithCachedTypeInfo<TyKind<'tcx>>>);
impl<'tcx> IntoKind for Ty<'tcx> {
type Kind = TyKind<'tcx>;
fn kind(&self) -> TyKind<'tcx> {
(*self).kind().clone()
fn kind(self) -> TyKind<'tcx> {
self.kind().clone()
}
}
@ -1553,17 +1548,17 @@ pub struct Placeholder<T> {
pub type PlaceholderRegion = Placeholder<BoundRegion>;
impl rustc_type_ir::Placeholder for PlaceholderRegion {
fn universe(&self) -> UniverseIndex {
impl PlaceholderLike for PlaceholderRegion {
fn universe(self) -> UniverseIndex {
self.universe
}
fn var(&self) -> BoundVar {
fn var(self) -> BoundVar {
self.bound.var
}
fn with_updated_universe(&self, ui: UniverseIndex) -> Self {
Placeholder { universe: ui, ..*self }
fn with_updated_universe(self, ui: UniverseIndex) -> Self {
Placeholder { universe: ui, ..self }
}
fn new(ui: UniverseIndex, var: BoundVar) -> Self {
@ -1573,17 +1568,17 @@ impl rustc_type_ir::Placeholder for PlaceholderRegion {
pub type PlaceholderType = Placeholder<BoundTy>;
impl rustc_type_ir::Placeholder for PlaceholderType {
fn universe(&self) -> UniverseIndex {
impl PlaceholderLike for PlaceholderType {
fn universe(self) -> UniverseIndex {
self.universe
}
fn var(&self) -> BoundVar {
fn var(self) -> BoundVar {
self.bound.var
}
fn with_updated_universe(&self, ui: UniverseIndex) -> Self {
Placeholder { universe: ui, ..*self }
fn with_updated_universe(self, ui: UniverseIndex) -> Self {
Placeholder { universe: ui, ..self }
}
fn new(ui: UniverseIndex, var: BoundVar) -> Self {
@ -1600,17 +1595,17 @@ pub struct BoundConst<'tcx> {
pub type PlaceholderConst = Placeholder<BoundVar>;
impl rustc_type_ir::Placeholder for PlaceholderConst {
fn universe(&self) -> UniverseIndex {
impl PlaceholderLike for PlaceholderConst {
fn universe(self) -> UniverseIndex {
self.universe
}
fn var(&self) -> BoundVar {
fn var(self) -> BoundVar {
self.bound
}
fn with_updated_universe(&self, ui: UniverseIndex) -> Self {
Placeholder { universe: ui, ..*self }
fn with_updated_universe(self, ui: UniverseIndex) -> Self {
Placeholder { universe: ui, ..self }
}
fn new(ui: UniverseIndex, var: BoundVar) -> Self {

View file

@ -1480,8 +1480,8 @@ pub struct Region<'tcx>(pub Interned<'tcx, RegionKind<'tcx>>);
impl<'tcx> IntoKind for Region<'tcx> {
type Kind = RegionKind<'tcx>;
fn kind(&self) -> RegionKind<'tcx> {
**self
fn kind(self) -> RegionKind<'tcx> {
*self
}
}