Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/next_solver/mapping.rs')
-rw-r--r--crates/hir-ty/src/next_solver/mapping.rs48
1 files changed, 45 insertions, 3 deletions
diff --git a/crates/hir-ty/src/next_solver/mapping.rs b/crates/hir-ty/src/next_solver/mapping.rs
index f3f74f67c0..1a5982cc00 100644
--- a/crates/hir-ty/src/next_solver/mapping.rs
+++ b/crates/hir-ty/src/next_solver/mapping.rs
@@ -143,10 +143,29 @@ pub trait ChalkToNextSolver<'db, Out> {
fn to_nextsolver(&self, interner: DbInterner<'db>) -> Out;
}
+impl<'db, A, OutA, B, OutB> ChalkToNextSolver<'db, (OutA, OutB)> for (A, B)
+where
+ A: ChalkToNextSolver<'db, OutA>,
+ B: ChalkToNextSolver<'db, OutB>,
+{
+ fn to_nextsolver(&self, interner: DbInterner<'db>) -> (OutA, OutB) {
+ (self.0.to_nextsolver(interner), self.1.to_nextsolver(interner))
+ }
+}
+
pub trait NextSolverToChalk<'db, Out> {
fn to_chalk(self, interner: DbInterner<'db>) -> Out;
}
+impl<'db, T, Out> NextSolverToChalk<'db, Option<Out>> for Option<T>
+where
+ T: NextSolverToChalk<'db, Out>,
+{
+ fn to_chalk(self, interner: DbInterner<'db>) -> Option<Out> {
+ self.map(|it| it.to_chalk(interner))
+ }
+}
+
impl NextSolverToChalk<'_, chalk_ir::Mutability> for rustc_ast_ir::Mutability {
fn to_chalk(self, interner: DbInterner<'_>) -> chalk_ir::Mutability {
match self {
@@ -520,7 +539,7 @@ impl<'db> ChalkToNextSolver<'db, Const<'db>> for chalk_ir::Const<Interner> {
ConstScalar::Bytes(bytes, memory) => {
rustc_type_ir::ConstKind::Value(ValueConst::new(
data.ty.to_nextsolver(interner),
- ConstBytes(bytes.clone(), memory.clone()),
+ ConstBytes { memory: bytes.clone(), memory_map: memory.clone() },
))
}
ConstScalar::UnevaluatedConst(c, subst) => {
@@ -633,6 +652,16 @@ impl<'db> ChalkToNextSolver<'db, GenericArg<'db>> for chalk_ir::GenericArg<Inter
}
}
+impl<'db> NextSolverToChalk<'db, crate::GenericArg> for GenericArg<'db> {
+ fn to_chalk(self, interner: DbInterner<'db>) -> crate::GenericArg {
+ match self {
+ GenericArg::Ty(ty) => ty.to_chalk(interner).cast(Interner),
+ GenericArg::Lifetime(region) => region.to_chalk(interner).cast(Interner),
+ GenericArg::Const(konst) => konst.to_chalk(interner).cast(Interner),
+ }
+ }
+}
+
impl<'db> ChalkToNextSolver<'db, GenericArgs<'db>> for chalk_ir::Substitution<Interner> {
fn to_nextsolver(&self, interner: DbInterner<'db>) -> GenericArgs<'db> {
GenericArgs::new_from_iter(
@@ -642,6 +671,17 @@ impl<'db> ChalkToNextSolver<'db, GenericArgs<'db>> for chalk_ir::Substitution<In
}
}
+impl<'db> ChalkToNextSolver<'db, crate::lower_nextsolver::ImplTraitIdx<'db>>
+ for crate::ImplTraitIdx
+{
+ fn to_nextsolver(
+ &self,
+ interner: DbInterner<'db>,
+ ) -> crate::lower_nextsolver::ImplTraitIdx<'db> {
+ crate::lower_nextsolver::ImplTraitIdx::from_raw(self.into_raw())
+ }
+}
+
impl<'db> NextSolverToChalk<'db, chalk_ir::Substitution<Interner>> for GenericArgs<'db> {
fn to_chalk(self, interner: DbInterner<'db>) -> chalk_ir::Substitution<Interner> {
convert_args_for_result(interner, self.as_slice())
@@ -1670,8 +1710,10 @@ pub fn convert_const_for_result<'db>(
let bytes = value_const.value.inner();
let value = chalk_ir::ConstValue::Concrete(chalk_ir::ConcreteConst {
// SAFETY: we will never actually use this without a database
- interned: ConstScalar::Bytes(bytes.0.clone(), unsafe {
- std::mem::transmute::<MemoryMap<'db>, MemoryMap<'static>>(bytes.1.clone())
+ interned: ConstScalar::Bytes(bytes.memory.clone(), unsafe {
+ std::mem::transmute::<MemoryMap<'db>, MemoryMap<'static>>(
+ bytes.memory_map.clone(),
+ )
}),
});
return chalk_ir::ConstData {