1
Fork 0

Don't transmute &List<GenericArg> <-> &List<Ty>

This commit is contained in:
Maybe Waffle 2023-04-18 17:42:30 +00:00
parent e8c0c1eafe
commit 10ec03c3fb
3 changed files with 30 additions and 55 deletions

View file

@ -60,6 +60,20 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Substitution<RustInterner<'tcx>>> for Subst
}
}
impl<'tcx> LowerInto<'tcx, chalk_ir::Substitution<RustInterner<'tcx>>>
for &'tcx ty::List<Ty<'tcx>>
{
fn lower_into(
self,
interner: RustInterner<'tcx>,
) -> chalk_ir::Substitution<RustInterner<'tcx>> {
chalk_ir::Substitution::from_iter(
interner,
self.iter().map(|ty| GenericArg::from(ty).lower_into(interner)),
)
}
}
impl<'tcx> LowerInto<'tcx, SubstsRef<'tcx>> for &chalk_ir::Substitution<RustInterner<'tcx>> {
fn lower_into(self, interner: RustInterner<'tcx>) -> SubstsRef<'tcx> {
interner
@ -351,9 +365,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
ty::GeneratorWitness(_) => unimplemented!(),
ty::GeneratorWitnessMIR(..) => unimplemented!(),
ty::Never => chalk_ir::TyKind::Never,
ty::Tuple(types) => {
chalk_ir::TyKind::Tuple(types.len(), types.as_substs().lower_into(interner))
}
ty::Tuple(types) => chalk_ir::TyKind::Tuple(types.len(), types.lower_into(interner)),
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),
@ -435,7 +447,7 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
TyKind::GeneratorWitness(..) => unimplemented!(),
TyKind::Never => ty::Never,
TyKind::Tuple(_len, substitution) => {
ty::Tuple(substitution.lower_into(interner).try_as_type_list().unwrap())
ty::Tuple(substitution.lower_into(interner).into_type_list(interner.tcx))
}
TyKind::Slice(ty) => ty::Slice(ty.lower_into(interner)),
TyKind::Raw(mutbl, ty) => ty::RawPtr(ty::TypeAndMut {