diff options
Diffstat (limited to 'crates/ra_hir_ty/src/traits')
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 7a0f99dec..7f7fe93b7 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs | |||
@@ -18,7 +18,7 @@ use crate::{ | |||
18 | }; | 18 | }; |
19 | 19 | ||
20 | #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] | 20 | #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] |
21 | pub struct Interner {} | 21 | pub struct Interner; |
22 | 22 | ||
23 | impl chalk_ir::interner::Interner for Interner { | 23 | impl chalk_ir::interner::Interner for Interner { |
24 | type InternedType = Box<chalk_ir::TyData<Self>>; | 24 | type InternedType = Box<chalk_ir::TyData<Self>>; |
@@ -59,7 +59,7 @@ impl chalk_ir::interner::Interner for Interner { | |||
59 | None | 59 | None |
60 | } | 60 | } |
61 | 61 | ||
62 | fn intern_ty(ty: chalk_ir::TyData<Self>) -> Box<chalk_ir::TyData<Self>> { | 62 | fn intern_ty(&self, ty: chalk_ir::TyData<Self>) -> Box<chalk_ir::TyData<Self>> { |
63 | Box::new(ty) | 63 | Box::new(ty) |
64 | } | 64 | } |
65 | 65 | ||
@@ -145,12 +145,12 @@ impl ToChalk for Ty { | |||
145 | Ty::Apply(apply_ty) => { | 145 | Ty::Apply(apply_ty) => { |
146 | let name = apply_ty.ctor.to_chalk(db); | 146 | let name = apply_ty.ctor.to_chalk(db); |
147 | let substitution = apply_ty.parameters.to_chalk(db); | 147 | let substitution = apply_ty.parameters.to_chalk(db); |
148 | chalk_ir::ApplicationTy { name, substitution }.cast().intern() | 148 | chalk_ir::ApplicationTy { name, substitution }.cast().intern(&Interner) |
149 | } | 149 | } |
150 | Ty::Projection(proj_ty) => { | 150 | Ty::Projection(proj_ty) => { |
151 | let associated_ty_id = proj_ty.associated_ty.to_chalk(db); | 151 | let associated_ty_id = proj_ty.associated_ty.to_chalk(db); |
152 | let substitution = proj_ty.parameters.to_chalk(db); | 152 | let substitution = proj_ty.parameters.to_chalk(db); |
153 | chalk_ir::AliasTy { associated_ty_id, substitution }.cast().intern() | 153 | chalk_ir::AliasTy { associated_ty_id, substitution }.cast().intern(&Interner) |
154 | } | 154 | } |
155 | Ty::Placeholder(id) => { | 155 | Ty::Placeholder(id) => { |
156 | let interned_id = db.intern_type_param_id(id); | 156 | let interned_id = db.intern_type_param_id(id); |
@@ -158,9 +158,9 @@ impl ToChalk for Ty { | |||
158 | ui: UniverseIndex::ROOT, | 158 | ui: UniverseIndex::ROOT, |
159 | idx: interned_id.as_intern_id().as_usize(), | 159 | idx: interned_id.as_intern_id().as_usize(), |
160 | } | 160 | } |
161 | .to_ty::<Interner>() | 161 | .to_ty::<Interner>(&Interner) |
162 | } | 162 | } |
163 | Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(), | 163 | Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(&Interner), |
164 | Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"), | 164 | Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"), |
165 | Ty::Dyn(predicates) => { | 165 | Ty::Dyn(predicates) => { |
166 | let where_clauses = predicates | 166 | let where_clauses = predicates |
@@ -170,12 +170,12 @@ impl ToChalk for Ty { | |||
170 | .map(|p| p.to_chalk(db)) | 170 | .map(|p| p.to_chalk(db)) |
171 | .collect(); | 171 | .collect(); |
172 | let bounded_ty = chalk_ir::DynTy { bounds: make_binders(where_clauses, 1) }; | 172 | let bounded_ty = chalk_ir::DynTy { bounds: make_binders(where_clauses, 1) }; |
173 | chalk_ir::TyData::Dyn(bounded_ty).intern() | 173 | chalk_ir::TyData::Dyn(bounded_ty).intern(&Interner) |
174 | } | 174 | } |
175 | Ty::Opaque(_) | Ty::Unknown => { | 175 | Ty::Opaque(_) | Ty::Unknown => { |
176 | let substitution = chalk_ir::Substitution::empty(); | 176 | let substitution = chalk_ir::Substitution::empty(); |
177 | let name = TypeName::Error; | 177 | let name = TypeName::Error; |
178 | chalk_ir::ApplicationTy { name, substitution }.cast().intern() | 178 | chalk_ir::ApplicationTy { name, substitution }.cast().intern(&Interner) |
179 | } | 179 | } |
180 | } | 180 | } |
181 | } | 181 | } |
@@ -612,6 +612,9 @@ where | |||
612 | _ => None, | 612 | _ => None, |
613 | } | 613 | } |
614 | } | 614 | } |
615 | fn interner(&self) -> &Interner { | ||
616 | &Interner | ||
617 | } | ||
615 | } | 618 | } |
616 | 619 | ||
617 | pub(crate) fn associated_ty_data_query( | 620 | pub(crate) fn associated_ty_data_query( |