diff options
Diffstat (limited to 'crates/hir_ty/src/traits/chalk')
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 6e6055d80..db1760e6c 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -10,7 +10,7 @@ use chalk_ir::{ | |||
10 | use chalk_solve::rust_ir; | 10 | use chalk_solve::rust_ir; |
11 | 11 | ||
12 | use base_db::salsa::InternKey; | 12 | use base_db::salsa::InternKey; |
13 | use hir_def::{type_ref::Mutability, AssocContainerId, GenericDefId, Lookup, TypeAliasId}; | 13 | use hir_def::{AssocContainerId, GenericDefId, Lookup, TypeAliasId}; |
14 | 14 | ||
15 | use crate::{ | 15 | use crate::{ |
16 | db::HirDatabase, | 16 | db::HirDatabase, |
@@ -65,7 +65,7 @@ impl ToChalk for Ty { | |||
65 | } | 65 | } |
66 | Ty::Raw(mutability, substs) => { | 66 | Ty::Raw(mutability, substs) => { |
67 | let ty = substs[0].clone().to_chalk(db); | 67 | let ty = substs[0].clone().to_chalk(db); |
68 | chalk_ir::TyKind::Raw(mutability.to_chalk(db), ty).intern(&Interner) | 68 | chalk_ir::TyKind::Raw(mutability, ty).intern(&Interner) |
69 | } | 69 | } |
70 | Ty::Slice(substs) => { | 70 | Ty::Slice(substs) => { |
71 | chalk_ir::TyKind::Slice(substs[0].clone().to_chalk(db)).intern(&Interner) | 71 | chalk_ir::TyKind::Slice(substs[0].clone().to_chalk(db)).intern(&Interner) |
@@ -198,11 +198,11 @@ impl ToChalk for Ty { | |||
198 | Ty::Tuple(cardinality, from_chalk(db, subst)) | 198 | Ty::Tuple(cardinality, from_chalk(db, subst)) |
199 | } | 199 | } |
200 | chalk_ir::TyKind::Raw(mutability, ty) => { | 200 | chalk_ir::TyKind::Raw(mutability, ty) => { |
201 | Ty::Raw(from_chalk(db, mutability), Substs::single(from_chalk(db, ty))) | 201 | Ty::Raw(mutability, Substs::single(from_chalk(db, ty))) |
202 | } | 202 | } |
203 | chalk_ir::TyKind::Slice(ty) => Ty::Slice(Substs::single(from_chalk(db, ty))), | 203 | chalk_ir::TyKind::Slice(ty) => Ty::Slice(Substs::single(from_chalk(db, ty))), |
204 | chalk_ir::TyKind::Ref(mutability, _lifetime, ty) => { | 204 | chalk_ir::TyKind::Ref(mutability, _lifetime, ty) => { |
205 | Ty::Ref(from_chalk(db, mutability), Substs::single(from_chalk(db, ty))) | 205 | Ty::Ref(mutability, Substs::single(from_chalk(db, ty))) |
206 | } | 206 | } |
207 | chalk_ir::TyKind::Str => Ty::Str, | 207 | chalk_ir::TyKind::Str => Ty::Str, |
208 | chalk_ir::TyKind::Never => Ty::Never, | 208 | chalk_ir::TyKind::Never => Ty::Never, |
@@ -230,12 +230,12 @@ impl ToChalk for Ty { | |||
230 | /// fake lifetime here, because Chalks built-in logic may expect it to be there. | 230 | /// fake lifetime here, because Chalks built-in logic may expect it to be there. |
231 | fn ref_to_chalk( | 231 | fn ref_to_chalk( |
232 | db: &dyn HirDatabase, | 232 | db: &dyn HirDatabase, |
233 | mutability: Mutability, | 233 | mutability: chalk_ir::Mutability, |
234 | subst: Substs, | 234 | subst: Substs, |
235 | ) -> chalk_ir::Ty<Interner> { | 235 | ) -> chalk_ir::Ty<Interner> { |
236 | let arg = subst[0].clone().to_chalk(db); | 236 | let arg = subst[0].clone().to_chalk(db); |
237 | let lifetime = LifetimeData::Static.intern(&Interner); | 237 | let lifetime = LifetimeData::Static.intern(&Interner); |
238 | chalk_ir::TyKind::Ref(mutability.to_chalk(db), lifetime, arg).intern(&Interner) | 238 | chalk_ir::TyKind::Ref(mutability, lifetime, arg).intern(&Interner) |
239 | } | 239 | } |
240 | 240 | ||
241 | /// We currently don't model constants, but Chalk does. So, we have to insert a | 241 | /// We currently don't model constants, but Chalk does. So, we have to insert a |
@@ -313,22 +313,6 @@ impl ToChalk for OpaqueTyId { | |||
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | impl ToChalk for Mutability { | ||
317 | type Chalk = chalk_ir::Mutability; | ||
318 | fn to_chalk(self, _db: &dyn HirDatabase) -> Self::Chalk { | ||
319 | match self { | ||
320 | Mutability::Shared => chalk_ir::Mutability::Not, | ||
321 | Mutability::Mut => chalk_ir::Mutability::Mut, | ||
322 | } | ||
323 | } | ||
324 | fn from_chalk(_db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { | ||
325 | match chalk { | ||
326 | chalk_ir::Mutability::Mut => Mutability::Mut, | ||
327 | chalk_ir::Mutability::Not => Mutability::Shared, | ||
328 | } | ||
329 | } | ||
330 | } | ||
331 | |||
332 | impl ToChalk for hir_def::ImplId { | 316 | impl ToChalk for hir_def::ImplId { |
333 | type Chalk = ImplId; | 317 | type Chalk = ImplId; |
334 | 318 | ||