From 27fe68ad5c908d439af6cfbe7748c56eb6f107fc Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 22 May 2020 17:50:58 +0200 Subject: Use TypeCtorId as AdtId directly, and rename the type alias StructId -> AdtId --- crates/ra_hir_ty/src/traits/chalk.rs | 16 ++++++++-------- crates/ra_hir_ty/src/traits/chalk/interner.rs | 6 +++--- crates/ra_hir_ty/src/traits/chalk/tls.rs | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'crates/ra_hir_ty/src/traits') diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 6c286ead7..e2f2a9ccb 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs @@ -45,7 +45,7 @@ impl<'a> chalk_solve::RustIrDatabase for ChalkContext<'a> { fn trait_datum(&self, trait_id: TraitId) -> Arc { self.db.trait_datum(self.krate, trait_id) } - fn adt_datum(&self, struct_id: StructId) -> Arc { + fn adt_datum(&self, struct_id: AdtId) -> Arc { self.db.struct_datum(self.krate, struct_id) } fn impl_datum(&self, impl_id: ImplId) -> Arc { @@ -94,7 +94,7 @@ impl<'a> chalk_solve::RustIrDatabase for ChalkContext<'a> { debug!("impls_for_trait returned {} impls", result.len()); result } - fn impl_provided_for(&self, auto_trait_id: TraitId, struct_id: StructId) -> bool { + fn impl_provided_for(&self, auto_trait_id: TraitId, struct_id: AdtId) -> bool { debug!("impl_provided_for {:?}, {:?}", auto_trait_id, struct_id); false // FIXME } @@ -257,7 +257,7 @@ fn lang_attr_from_well_known_trait(attr: WellKnownTrait) -> &'static str { pub(crate) fn struct_datum_query( db: &dyn HirDatabase, krate: CrateId, - struct_id: StructId, + struct_id: AdtId, ) -> Arc { debug!("struct_datum {:?}", struct_id); let type_ctor: TypeCtor = from_chalk(db, TypeName::Adt(struct_id)); @@ -405,15 +405,15 @@ fn type_alias_associated_ty_value( Arc::new(value) } -impl From for crate::TypeCtorId { - fn from(struct_id: StructId) -> Self { - InternKey::from_intern_id(struct_id.0) +impl From for crate::TypeCtorId { + fn from(struct_id: AdtId) -> Self { + struct_id.0 } } -impl From for StructId { +impl From for AdtId { fn from(type_ctor_id: crate::TypeCtorId) -> Self { - chalk_ir::AdtId(type_ctor_id.as_intern_id()) + chalk_ir::AdtId(type_ctor_id) } } diff --git a/crates/ra_hir_ty/src/traits/chalk/interner.rs b/crates/ra_hir_ty/src/traits/chalk/interner.rs index 032deca75..d98e5cb2d 100644 --- a/crates/ra_hir_ty/src/traits/chalk/interner.rs +++ b/crates/ra_hir_ty/src/traits/chalk/interner.rs @@ -14,7 +14,7 @@ pub type AssocTypeId = chalk_ir::AssocTypeId; pub type AssociatedTyDatum = chalk_rust_ir::AssociatedTyDatum; pub type TraitId = chalk_ir::TraitId; pub type TraitDatum = chalk_rust_ir::TraitDatum; -pub type StructId = chalk_ir::AdtId; +pub type AdtId = chalk_ir::AdtId; pub type StructDatum = chalk_rust_ir::AdtDatum; pub type ImplId = chalk_ir::ImplId; pub type ImplDatum = chalk_rust_ir::ImplDatum; @@ -36,10 +36,10 @@ impl chalk_ir::interner::Interner for Interner { type InternedVariableKinds = Vec>; type InternedCanonicalVarKinds = Vec>; type DefId = InternId; - type InternedAdtId = InternId; + type InternedAdtId = crate::TypeCtorId; type Identifier = TypeAliasId; - fn debug_adt_id(type_kind_id: StructId, fmt: &mut fmt::Formatter<'_>) -> Option { + fn debug_adt_id(type_kind_id: AdtId, fmt: &mut fmt::Formatter<'_>) -> Option { tls::with_current_program(|prog| Some(prog?.debug_struct_id(type_kind_id, fmt))) } diff --git a/crates/ra_hir_ty/src/traits/chalk/tls.rs b/crates/ra_hir_ty/src/traits/chalk/tls.rs index b7eb49d7b..5dfd8e3ec 100644 --- a/crates/ra_hir_ty/src/traits/chalk/tls.rs +++ b/crates/ra_hir_ty/src/traits/chalk/tls.rs @@ -15,7 +15,7 @@ pub struct DebugContext<'a>(&'a (dyn HirDatabase + 'a)); impl DebugContext<'_> { pub fn debug_struct_id( &self, - id: super::StructId, + id: super::AdtId, f: &mut fmt::Formatter<'_>, ) -> Result<(), fmt::Error> { let type_ctor: TypeCtor = from_chalk(self.0, TypeName::Adt(id)); -- cgit v1.2.3