diff options
author | Lukas Wirth <[email protected]> | 2021-03-01 20:57:39 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-03-04 18:38:02 +0000 |
commit | 50e01d2bc7429d718e0783d75458a6a047ee2b70 (patch) | |
tree | 5043387dfce7e3fc96777ce5983048f0d2d450e5 /crates/hir_ty/src/traits | |
parent | 16a76aa158d0898d6a46d7bba7310150555a69b9 (diff) |
Use chalk_ir::AdtId
Diffstat (limited to 'crates/hir_ty/src/traits')
-rw-r--r-- | crates/hir_ty/src/traits/chalk.rs | 14 | ||||
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 16 |
2 files changed, 8 insertions, 22 deletions
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index e513fa8f4..4378a9723 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs | |||
@@ -315,9 +315,8 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
315 | let id = from_chalk(self.db, trait_id); | 315 | let id = from_chalk(self.db, trait_id); |
316 | self.db.trait_data(id).name.to_string() | 316 | self.db.trait_data(id).name.to_string() |
317 | } | 317 | } |
318 | fn adt_name(&self, adt_id: chalk_ir::AdtId<Interner>) -> String { | 318 | fn adt_name(&self, chalk_ir::AdtId(adt_id): AdtId) -> String { |
319 | let id = from_chalk(self.db, adt_id); | 319 | match adt_id { |
320 | match id { | ||
321 | hir_def::AdtId::StructId(id) => self.db.struct_data(id).name.to_string(), | 320 | hir_def::AdtId::StructId(id) => self.db.struct_data(id).name.to_string(), |
322 | hir_def::AdtId::EnumId(id) => self.db.enum_data(id).name.to_string(), | 321 | hir_def::AdtId::EnumId(id) => self.db.enum_data(id).name.to_string(), |
323 | hir_def::AdtId::UnionId(id) => self.db.union_data(id).name.to_string(), | 322 | hir_def::AdtId::UnionId(id) => self.db.union_data(id).name.to_string(), |
@@ -488,8 +487,8 @@ pub(crate) fn struct_datum_query( | |||
488 | struct_id: AdtId, | 487 | struct_id: AdtId, |
489 | ) -> Arc<StructDatum> { | 488 | ) -> Arc<StructDatum> { |
490 | debug!("struct_datum {:?}", struct_id); | 489 | debug!("struct_datum {:?}", struct_id); |
491 | let adt_id = from_chalk(db, struct_id); | 490 | let type_ctor = Ty::Adt(struct_id, Substs::empty()); |
492 | let type_ctor = Ty::Adt(adt_id, Substs::empty()); | 491 | let chalk_ir::AdtId(adt_id) = struct_id; |
493 | debug!("struct {:?} = {:?}", struct_id, type_ctor); | 492 | debug!("struct {:?} = {:?}", struct_id, type_ctor); |
494 | let num_params = generics(db.upcast(), adt_id.into()).len(); | 493 | let num_params = generics(db.upcast(), adt_id.into()).len(); |
495 | let upstream = adt_id.module(db.upcast()).krate() != krate; | 494 | let upstream = adt_id.module(db.upcast()).krate() != krate; |
@@ -684,10 +683,9 @@ pub(crate) fn fn_def_variance_query( | |||
684 | pub(crate) fn adt_variance_query( | 683 | pub(crate) fn adt_variance_query( |
685 | db: &dyn HirDatabase, | 684 | db: &dyn HirDatabase, |
686 | _krate: CrateId, | 685 | _krate: CrateId, |
687 | adt_id: AdtId, | 686 | chalk_ir::AdtId(adt_id): AdtId, |
688 | ) -> Variances { | 687 | ) -> Variances { |
689 | let adt: crate::AdtId = from_chalk(db, adt_id); | 688 | let generic_params = generics(db.upcast(), adt_id.into()); |
690 | let generic_params = generics(db.upcast(), adt.into()); | ||
691 | Variances::from_iter( | 689 | Variances::from_iter( |
692 | &Interner, | 690 | &Interner, |
693 | std::iter::repeat(chalk_ir::Variance::Invariant).take(generic_params.len()), | 691 | std::iter::repeat(chalk_ir::Variance::Invariant).take(generic_params.len()), |
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index db1760e6c..3a08b67e9 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -86,7 +86,7 @@ impl ToChalk for Ty { | |||
86 | 86 | ||
87 | Ty::Adt(adt_id, substs) => { | 87 | Ty::Adt(adt_id, substs) => { |
88 | let substitution = substs.to_chalk(db); | 88 | let substitution = substs.to_chalk(db); |
89 | chalk_ir::TyKind::Adt(chalk_ir::AdtId(adt_id), substitution).intern(&Interner) | 89 | chalk_ir::TyKind::Adt(adt_id, substitution).intern(&Interner) |
90 | } | 90 | } |
91 | Ty::Alias(AliasTy::Projection(proj_ty)) => { | 91 | Ty::Alias(AliasTy::Projection(proj_ty)) => { |
92 | let associated_ty_id = TypeAliasAsAssocType(proj_ty.associated_ty).to_chalk(db); | 92 | let associated_ty_id = TypeAliasAsAssocType(proj_ty.associated_ty).to_chalk(db); |
@@ -183,7 +183,7 @@ impl ToChalk for Ty { | |||
183 | Ty::Dyn(predicates) | 183 | Ty::Dyn(predicates) |
184 | } | 184 | } |
185 | 185 | ||
186 | chalk_ir::TyKind::Adt(struct_id, subst) => Ty::Adt(struct_id.0, from_chalk(db, subst)), | 186 | chalk_ir::TyKind::Adt(adt_id, subst) => Ty::Adt(adt_id, from_chalk(db, subst)), |
187 | chalk_ir::TyKind::AssociatedType(type_id, subst) => Ty::AssociatedType( | 187 | chalk_ir::TyKind::AssociatedType(type_id, subst) => Ty::AssociatedType( |
188 | from_chalk::<TypeAliasAsAssocType, _>(db, type_id).0, | 188 | from_chalk::<TypeAliasAsAssocType, _>(db, type_id).0, |
189 | from_chalk(db, subst), | 189 | from_chalk(db, subst), |
@@ -325,18 +325,6 @@ impl ToChalk for hir_def::ImplId { | |||
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | impl ToChalk for hir_def::AdtId { | ||
329 | type Chalk = AdtId; | ||
330 | |||
331 | fn to_chalk(self, _db: &dyn HirDatabase) -> Self::Chalk { | ||
332 | chalk_ir::AdtId(self.into()) | ||
333 | } | ||
334 | |||
335 | fn from_chalk(_db: &dyn HirDatabase, id: AdtId) -> Self { | ||
336 | id.0 | ||
337 | } | ||
338 | } | ||
339 | |||
340 | impl ToChalk for CallableDefId { | 328 | impl ToChalk for CallableDefId { |
341 | type Chalk = FnDefId; | 329 | type Chalk = FnDefId; |
342 | 330 | ||