diff options
-rw-r--r-- | crates/hir_ty/src/traits/chalk.rs | 14 | ||||
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 12 |
2 files changed, 21 insertions, 5 deletions
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index 17c83b6a4..01b5717a3 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs | |||
@@ -244,13 +244,17 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
244 | let id = from_chalk(self.db, trait_id); | 244 | let id = from_chalk(self.db, trait_id); |
245 | self.db.trait_data(id).name.to_string() | 245 | self.db.trait_data(id).name.to_string() |
246 | } | 246 | } |
247 | // FIXME: lookup names | 247 | fn adt_name(&self, adt_id: chalk_ir::AdtId<Interner>) -> String { |
248 | fn adt_name(&self, struct_id: chalk_ir::AdtId<Interner>) -> String { | 248 | let id = from_chalk(self.db, adt_id); |
249 | let datum = self.db.struct_datum(self.krate, struct_id); | 249 | match id { |
250 | format!("{:?}", datum.name(&Interner)) | 250 | hir_def::AdtId::StructId(id) => self.db.struct_data(id).name.to_string(), |
251 | hir_def::AdtId::EnumId(id) => self.db.enum_data(id).name.to_string(), | ||
252 | hir_def::AdtId::UnionId(id) => self.db.union_data(id).name.to_string(), | ||
253 | } | ||
251 | } | 254 | } |
252 | fn assoc_type_name(&self, assoc_ty_id: chalk_ir::AssocTypeId<Interner>) -> String { | 255 | fn assoc_type_name(&self, assoc_ty_id: chalk_ir::AssocTypeId<Interner>) -> String { |
253 | format!("Assoc_{}", assoc_ty_id.0) | 256 | let id = self.db.associated_ty_data(assoc_ty_id).name; |
257 | self.db.type_alias_data(id).name.to_string() | ||
254 | } | 258 | } |
255 | fn opaque_type_name(&self, opaque_ty_id: chalk_ir::OpaqueTyId<Interner>) -> String { | 259 | fn opaque_type_name(&self, opaque_ty_id: chalk_ir::OpaqueTyId<Interner>) -> String { |
256 | format!("Opaque_{}", opaque_ty_id.0) | 260 | format!("Opaque_{}", opaque_ty_id.0) |
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index fe62f3fa7..d6bacba1d 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -464,6 +464,18 @@ impl ToChalk for hir_def::ImplId { | |||
464 | } | 464 | } |
465 | } | 465 | } |
466 | 466 | ||
467 | impl ToChalk for hir_def::AdtId { | ||
468 | type Chalk = AdtId; | ||
469 | |||
470 | fn to_chalk(self, _db: &dyn HirDatabase) -> Self::Chalk { | ||
471 | chalk_ir::AdtId(self.into()) | ||
472 | } | ||
473 | |||
474 | fn from_chalk(_db: &dyn HirDatabase, id: AdtId) -> Self { | ||
475 | id.0 | ||
476 | } | ||
477 | } | ||
478 | |||
467 | impl ToChalk for CallableDefId { | 479 | impl ToChalk for CallableDefId { |
468 | type Chalk = FnDefId; | 480 | type Chalk = FnDefId; |
469 | 481 | ||