diff --git a/crates/hir_ty/src/chalk_ext.rs b/crates/hir_ty/src/chalk_ext.rs index 28ed3aac6d49..8c4542956284 100644 --- a/crates/hir_ty/src/chalk_ext.rs +++ b/crates/hir_ty/src/chalk_ext.rs @@ -75,7 +75,7 @@ fn as_fn_def(&self, db: &dyn HirDatabase) -> Option { } fn as_reference(&self) -> Option<(&Ty, Lifetime, Mutability)> { match self.kind(&Interner) { - TyKind::Ref(mutability, lifetime, ty) => Some((ty, *lifetime, *mutability)), + TyKind::Ref(mutability, lifetime, ty) => Some((ty, lifetime.clone(), *mutability)), _ => None, } } diff --git a/crates/hir_ty/src/traits/chalk/interner.rs b/crates/hir_ty/src/traits/chalk/interner.rs index 83787b8c0dc9..3a6ceef05bf2 100644 --- a/crates/hir_ty/src/traits/chalk/interner.rs +++ b/crates/hir_ty/src/traits/chalk/interner.rs @@ -39,16 +39,29 @@ #[derive(PartialEq, Eq, Hash, Debug)] pub struct InternedTypeInner(chalk_ir::TyData); +#[derive(PartialEq, Eq, Hash, Debug)] +pub struct InternedWrapper(T); + +impl std::ops::Deref for InternedWrapper { + type Target = T; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + impl_internable!( InternedVariableKindsInner, InternedSubstitutionInner, InternedTypeInner, + InternedWrapper>, + InternedWrapper>, ); impl chalk_ir::interner::Interner for Interner { type InternedType = Interned; - type InternedLifetime = chalk_ir::LifetimeData; - type InternedConst = Arc>; + type InternedLifetime = Interned>>; + type InternedConst = Interned>>; type InternedConcreteConst = (); type InternedGenericArg = chalk_ir::GenericArgData; type InternedGoal = Arc>; @@ -221,22 +234,22 @@ fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData } fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData) -> Self::InternedLifetime { - lifetime + Interned::new(InternedWrapper(lifetime)) } fn lifetime_data<'a>( &self, lifetime: &'a Self::InternedLifetime, ) -> &'a chalk_ir::LifetimeData { - lifetime + &lifetime.0 } fn intern_const(&self, constant: chalk_ir::ConstData) -> Self::InternedConst { - Arc::new(constant) + Interned::new(InternedWrapper(constant)) } fn const_data<'a>(&self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData { - constant + &constant.0 } fn const_eq(