aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/traits/chalk
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-03-13 16:23:19 +0000
committerFlorian Diebold <[email protected]>2021-03-13 16:56:48 +0000
commitdfafcd926a4cc9b09aba0eb3cc5275a4abe633b9 (patch)
treecfb4000f57a35b2dc2fdab78a5b422fc3af3667e /crates/hir_ty/src/traits/chalk
parentd4533785698d439417bc5474fecd62a7f1707368 (diff)
Use chalk_ir::ForeignDefId
Diffstat (limited to 'crates/hir_ty/src/traits/chalk')
-rw-r--r--crates/hir_ty/src/traits/chalk/interner.rs1
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs24
2 files changed, 2 insertions, 23 deletions
diff --git a/crates/hir_ty/src/traits/chalk/interner.rs b/crates/hir_ty/src/traits/chalk/interner.rs
index 54bd1c724..e891efb7b 100644
--- a/crates/hir_ty/src/traits/chalk/interner.rs
+++ b/crates/hir_ty/src/traits/chalk/interner.rs
@@ -12,7 +12,6 @@ pub struct Interner;
12 12
13pub(crate) type AssocTypeId = chalk_ir::AssocTypeId<Interner>; 13pub(crate) type AssocTypeId = chalk_ir::AssocTypeId<Interner>;
14pub(crate) type AssociatedTyDatum = chalk_solve::rust_ir::AssociatedTyDatum<Interner>; 14pub(crate) type AssociatedTyDatum = chalk_solve::rust_ir::AssociatedTyDatum<Interner>;
15pub(crate) type ForeignDefId = chalk_ir::ForeignDefId<Interner>;
16pub(crate) type TraitId = chalk_ir::TraitId<Interner>; 15pub(crate) type TraitId = chalk_ir::TraitId<Interner>;
17pub(crate) type TraitDatum = chalk_solve::rust_ir::TraitDatum<Interner>; 16pub(crate) type TraitDatum = chalk_solve::rust_ir::TraitDatum<Interner>;
18pub(crate) type AdtId = chalk_ir::AdtId<Interner>; 17pub(crate) type AdtId = chalk_ir::AdtId<Interner>;
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 44cfb9359..cf490f9c5 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -51,11 +51,7 @@ impl ToChalk for Ty {
51 chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner) 51 chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner)
52 } 52 }
53 53
54 TyKind::ForeignType(type_alias) => { 54 TyKind::ForeignType(id) => chalk_ir::TyKind::Foreign(id).intern(&Interner),
55 let foreign_type = TypeAliasAsForeignType(type_alias);
56 let foreign_type_id = foreign_type.to_chalk(db);
57 chalk_ir::TyKind::Foreign(foreign_type_id).intern(&Interner)
58 }
59 55
60 TyKind::Scalar(scalar) => chalk_ir::TyKind::Scalar(scalar).intern(&Interner), 56 TyKind::Scalar(scalar) => chalk_ir::TyKind::Scalar(scalar).intern(&Interner),
61 57
@@ -217,9 +213,7 @@ impl ToChalk for Ty {
217 TyKind::Closure(def, expr, from_chalk(db, subst)) 213 TyKind::Closure(def, expr, from_chalk(db, subst))
218 } 214 }
219 215
220 chalk_ir::TyKind::Foreign(foreign_def_id) => { 216 chalk_ir::TyKind::Foreign(foreign_def_id) => TyKind::ForeignType(foreign_def_id),
221 TyKind::ForeignType(from_chalk::<TypeAliasAsForeignType, _>(db, foreign_def_id).0)
222 }
223 chalk_ir::TyKind::Generator(_, _) => unimplemented!(), // FIXME 217 chalk_ir::TyKind::Generator(_, _) => unimplemented!(), // FIXME
224 chalk_ir::TyKind::GeneratorWitness(_, _) => unimplemented!(), // FIXME 218 chalk_ir::TyKind::GeneratorWitness(_, _) => unimplemented!(), // FIXME
225 } 219 }
@@ -352,20 +346,6 @@ impl ToChalk for TypeAliasAsAssocType {
352 } 346 }
353} 347}
354 348
355pub(crate) struct TypeAliasAsForeignType(pub(crate) TypeAliasId);
356
357impl ToChalk for TypeAliasAsForeignType {
358 type Chalk = ForeignDefId;
359
360 fn to_chalk(self, _db: &dyn HirDatabase) -> ForeignDefId {
361 chalk_ir::ForeignDefId(self.0.as_intern_id())
362 }
363
364 fn from_chalk(_db: &dyn HirDatabase, foreign_def_id: ForeignDefId) -> TypeAliasAsForeignType {
365 TypeAliasAsForeignType(InternKey::from_intern_id(foreign_def_id.0))
366 }
367}
368
369pub(crate) struct TypeAliasAsValue(pub(crate) TypeAliasId); 349pub(crate) struct TypeAliasAsValue(pub(crate) TypeAliasId);
370 350
371impl ToChalk for TypeAliasAsValue { 351impl ToChalk for TypeAliasAsValue {