aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r--crates/hir_ty/src/chalk_ext.rs2
-rw-r--r--crates/hir_ty/src/traits/chalk/interner.rs25
2 files changed, 20 insertions, 7 deletions
diff --git a/crates/hir_ty/src/chalk_ext.rs b/crates/hir_ty/src/chalk_ext.rs
index 28ed3aac6..8c4542956 100644
--- a/crates/hir_ty/src/chalk_ext.rs
+++ b/crates/hir_ty/src/chalk_ext.rs
@@ -75,7 +75,7 @@ impl TyExt for Ty {
75 } 75 }
76 fn as_reference(&self) -> Option<(&Ty, Lifetime, Mutability)> { 76 fn as_reference(&self) -> Option<(&Ty, Lifetime, Mutability)> {
77 match self.kind(&Interner) { 77 match self.kind(&Interner) {
78 TyKind::Ref(mutability, lifetime, ty) => Some((ty, *lifetime, *mutability)), 78 TyKind::Ref(mutability, lifetime, ty) => Some((ty, lifetime.clone(), *mutability)),
79 _ => None, 79 _ => None,
80 } 80 }
81 } 81 }
diff --git a/crates/hir_ty/src/traits/chalk/interner.rs b/crates/hir_ty/src/traits/chalk/interner.rs
index 83787b8c0..3a6ceef05 100644
--- a/crates/hir_ty/src/traits/chalk/interner.rs
+++ b/crates/hir_ty/src/traits/chalk/interner.rs
@@ -39,16 +39,29 @@ pub struct InternedSubstitutionInner(SmallVec<[GenericArg; 2]>);
39#[derive(PartialEq, Eq, Hash, Debug)] 39#[derive(PartialEq, Eq, Hash, Debug)]
40pub struct InternedTypeInner(chalk_ir::TyData<Interner>); 40pub struct InternedTypeInner(chalk_ir::TyData<Interner>);
41 41
42#[derive(PartialEq, Eq, Hash, Debug)]
43pub struct InternedWrapper<T>(T);
44
45impl<T> std::ops::Deref for InternedWrapper<T> {
46 type Target = T;
47
48 fn deref(&self) -> &Self::Target {
49 &self.0
50 }
51}
52
42impl_internable!( 53impl_internable!(
43 InternedVariableKindsInner, 54 InternedVariableKindsInner,
44 InternedSubstitutionInner, 55 InternedSubstitutionInner,
45 InternedTypeInner, 56 InternedTypeInner,
57 InternedWrapper<chalk_ir::LifetimeData<Interner>>,
58 InternedWrapper<chalk_ir::ConstData<Interner>>,
46); 59);
47 60
48impl chalk_ir::interner::Interner for Interner { 61impl chalk_ir::interner::Interner for Interner {
49 type InternedType = Interned<InternedTypeInner>; 62 type InternedType = Interned<InternedTypeInner>;
50 type InternedLifetime = chalk_ir::LifetimeData<Self>; 63 type InternedLifetime = Interned<InternedWrapper<chalk_ir::LifetimeData<Self>>>;
51 type InternedConst = Arc<chalk_ir::ConstData<Self>>; 64 type InternedConst = Interned<InternedWrapper<chalk_ir::ConstData<Self>>>;
52 type InternedConcreteConst = (); 65 type InternedConcreteConst = ();
53 type InternedGenericArg = chalk_ir::GenericArgData<Self>; 66 type InternedGenericArg = chalk_ir::GenericArgData<Self>;
54 type InternedGoal = Arc<GoalData<Self>>; 67 type InternedGoal = Arc<GoalData<Self>>;
@@ -221,22 +234,22 @@ impl chalk_ir::interner::Interner for Interner {
221 } 234 }
222 235
223 fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData<Self>) -> Self::InternedLifetime { 236 fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData<Self>) -> Self::InternedLifetime {
224 lifetime 237 Interned::new(InternedWrapper(lifetime))
225 } 238 }
226 239
227 fn lifetime_data<'a>( 240 fn lifetime_data<'a>(
228 &self, 241 &self,
229 lifetime: &'a Self::InternedLifetime, 242 lifetime: &'a Self::InternedLifetime,
230 ) -> &'a chalk_ir::LifetimeData<Self> { 243 ) -> &'a chalk_ir::LifetimeData<Self> {
231 lifetime 244 &lifetime.0
232 } 245 }
233 246
234 fn intern_const(&self, constant: chalk_ir::ConstData<Self>) -> Self::InternedConst { 247 fn intern_const(&self, constant: chalk_ir::ConstData<Self>) -> Self::InternedConst {
235 Arc::new(constant) 248 Interned::new(InternedWrapper(constant))
236 } 249 }
237 250
238 fn const_data<'a>(&self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData<Self> { 251 fn const_data<'a>(&self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData<Self> {
239 constant 252 &constant.0
240 } 253 }
241 254
242 fn const_eq( 255 fn const_eq(