From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_traits/src/chalk/lowering.rs | 63 ++++++++++++++++------------- 1 file changed, 35 insertions(+), 28 deletions(-) (limited to 'compiler/rustc_traits/src/chalk/lowering.rs') diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index c4ab86e9e..9712abb70 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -66,15 +66,6 @@ impl<'tcx> LowerInto<'tcx, SubstsRef<'tcx>> for &chalk_ir::Substitution LowerInto<'tcx, chalk_ir::AliasTy>> for ty::ProjectionTy<'tcx> { - fn lower_into(self, interner: RustInterner<'tcx>) -> chalk_ir::AliasTy> { - chalk_ir::AliasTy::Projection(chalk_ir::ProjectionTy { - associated_ty_id: chalk_ir::AssocTypeId(self.item_def_id), - substitution: self.substs.lower_into(interner), - }) - } -} - impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment>>> for ChalkEnvironmentAndGoal<'tcx> { @@ -255,7 +246,10 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::AliasEq>> // FIXME(associated_const_equality): teach chalk about terms for alias eq. chalk_ir::AliasEq { ty: self.term.ty().unwrap().lower_into(interner), - alias: self.projection_ty.lower_into(interner), + alias: chalk_ir::AliasTy::Projection(chalk_ir::ProjectionTy { + associated_ty_id: chalk_ir::AssocTypeId(self.projection_ty.def_id), + substitution: self.projection_ty.substs.lower_into(interner), + }), } } } @@ -353,8 +347,13 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty>> for Ty<'tcx> { ty::Tuple(types) => { chalk_ir::TyKind::Tuple(types.len(), types.as_substs().lower_into(interner)) } - ty::Projection(proj) => chalk_ir::TyKind::Alias(proj.lower_into(interner)), - ty::Opaque(def_id, substs) => { + ty::Alias(ty::Projection, ty::AliasTy { def_id, substs, .. }) => { + chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(chalk_ir::ProjectionTy { + associated_ty_id: chalk_ir::AssocTypeId(def_id), + substitution: substs.lower_into(interner), + })) + } + ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => { chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy { opaque_ty_id: chalk_ir::OpaqueTyId(def_id), substitution: substs.lower_into(interner), @@ -442,13 +441,14 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty> { mutbl.lower_into(interner), ), TyKind::Str => ty::Str, - TyKind::OpaqueType(opaque_ty, substitution) => { - ty::Opaque(opaque_ty.0, substitution.lower_into(interner)) - } - TyKind::AssociatedType(assoc_ty, substitution) => ty::Projection(ty::ProjectionTy { - substs: substitution.lower_into(interner), - item_def_id: assoc_ty.0, - }), + TyKind::OpaqueType(opaque_ty, substitution) => ty::Alias( + ty::Opaque, + interner.tcx.mk_alias_ty(opaque_ty.0, substitution.lower_into(interner)), + ), + TyKind::AssociatedType(assoc_ty, substitution) => ty::Alias( + ty::Projection, + interner.tcx.mk_alias_ty(assoc_ty.0, substitution.lower_into(interner)), + ), TyKind::Foreign(def_id) => ty::Foreign(def_id.0), TyKind::Error => return interner.tcx.ty_error(), TyKind::Placeholder(placeholder) => ty::Placeholder(ty::Placeholder { @@ -456,13 +456,20 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty> { name: ty::BoundVar::from_usize(placeholder.idx), }), TyKind::Alias(alias_ty) => match alias_ty { - chalk_ir::AliasTy::Projection(projection) => ty::Projection(ty::ProjectionTy { - item_def_id: projection.associated_ty_id.0, - substs: projection.substitution.lower_into(interner), - }), - chalk_ir::AliasTy::Opaque(opaque) => { - ty::Opaque(opaque.opaque_ty_id.0, opaque.substitution.lower_into(interner)) - } + chalk_ir::AliasTy::Projection(projection) => ty::Alias( + ty::Projection, + interner.tcx.mk_alias_ty( + projection.associated_ty_id.0, + projection.substitution.lower_into(interner), + ), + ), + chalk_ir::AliasTy::Opaque(opaque) => ty::Alias( + ty::Opaque, + interner.tcx.mk_alias_ty( + opaque.opaque_ty_id.0, + opaque.substitution.lower_into(interner), + ), + ), }, TyKind::Function(_quantified_ty) => unimplemented!(), TyKind::BoundVar(_bound) => ty::Bound( @@ -688,7 +695,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders LowerInto<'tcx, chalk_solve::rust_ir::AliasEqBound let (trait_ref, own_substs) = self.projection_ty.trait_ref_and_own_substs(interner.tcx); chalk_solve::rust_ir::AliasEqBound { trait_bound: trait_ref.lower_into(interner), - associated_ty_id: chalk_ir::AssocTypeId(self.projection_ty.item_def_id), + associated_ty_id: chalk_ir::AssocTypeId(self.projection_ty.def_id), parameters: own_substs.iter().map(|arg| arg.lower_into(interner)).collect(), value: self.term.ty().unwrap().lower_into(interner), } -- cgit v1.2.3