Use ty::OpaqueTy everywhere

This commit is contained in:
Michael Goulet 2022-11-26 21:09:39 +00:00
parent 918ede6474
commit 7f3af72606
55 changed files with 156 additions and 118 deletions

View file

@ -432,7 +432,9 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
(ast::Mutability::Not, chalk_ir::Mutability::Not) => true,
}
}
(&ty::Opaque(def_id, ..), OpaqueType(opaque_ty_id, ..)) => def_id == opaque_ty_id.0,
(&ty::Opaque(ty::OpaqueTy { def_id, substs: _ }), OpaqueType(opaque_ty_id, ..)) => {
def_id == opaque_ty_id.0
}
(&ty::FnDef(def_id, ..), FnDef(fn_def_id, ..)) => def_id == fn_def_id.0,
(&ty::Str, Str) => true,
(&ty::Never, Never) => true,
@ -786,7 +788,7 @@ impl<'tcx> ty::TypeFolder<'tcx> for ReplaceOpaqueTyFolder<'tcx> {
}
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
if let ty::Opaque(def_id, substs) = *ty.kind() {
if let ty::Opaque(ty::OpaqueTy { def_id, substs }) = *ty.kind() {
if def_id == self.opaque_ty_id.0 && substs == self.identity_substs {
return self.tcx.mk_ty(ty::Bound(
self.binder_index,

View file

@ -354,7 +354,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
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::Opaque(ty::OpaqueTy { 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,9 +442,10 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
mutbl.lower_into(interner),
),
TyKind::Str => ty::Str,
TyKind::OpaqueType(opaque_ty, substitution) => {
ty::Opaque(opaque_ty.0, substitution.lower_into(interner))
}
TyKind::OpaqueType(opaque_ty, substitution) => ty::Opaque(ty::OpaqueTy {
def_id: opaque_ty.0,
substs: substitution.lower_into(interner),
}),
TyKind::AssociatedType(assoc_ty, substitution) => ty::Projection(ty::ProjectionTy {
substs: substitution.lower_into(interner),
item_def_id: assoc_ty.0,
@ -460,9 +461,10 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
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::Opaque(opaque) => ty::Opaque(ty::OpaqueTy {
def_id: opaque.opaque_ty_id.0,
substs: opaque.substitution.lower_into(interner),
}),
},
TyKind::Function(_quantified_ty) => unimplemented!(),
TyKind::BoundVar(_bound) => ty::Bound(