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/db.rs | 2 +- crates/ra_hir_ty/src/lib.rs | 2 +- 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 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs index fdb49560b..dfc6c7dd6 100644 --- a/crates/ra_hir_ty/src/db.rs +++ b/crates/ra_hir_ty/src/db.rs @@ -89,7 +89,7 @@ pub trait HirDatabase: DefDatabase + Upcast { fn trait_datum(&self, krate: CrateId, trait_id: chalk::TraitId) -> Arc; #[salsa::invoke(chalk::struct_datum_query)] - fn struct_datum(&self, krate: CrateId, struct_id: chalk::StructId) -> Arc; + fn struct_datum(&self, krate: CrateId, struct_id: chalk::AdtId) -> Arc; #[salsa::invoke(crate::traits::chalk::impl_datum_query)] fn impl_datum(&self, krate: CrateId, impl_id: chalk::ImplId) -> Arc; diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index c87ee06ce..e91c9be04 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -155,7 +155,7 @@ pub enum TypeCtor { /// This exists just for Chalk, because Chalk just has a single `StructId` where /// we have different kinds of ADTs, primitive types and special type /// constructors like tuples and function pointers. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] pub struct TypeCtorId(salsa::InternId); impl_intern_key!(TypeCtorId); 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