From c8a643f090ed88289c7bc17b48078e39b932c8a4 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Wed, 1 May 2019 17:06:11 +0200 Subject: Move Chalk conversion code to its own module --- crates/ra_hir/src/ids.rs | 50 ++++-------------------------------------------- 1 file changed, 4 insertions(+), 46 deletions(-) (limited to 'crates/ra_hir/src/ids.rs') diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index 6875b006d..ff4a81e59 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -323,25 +323,6 @@ impl AstItemDef for TraitId { } } -fn from_chalk(chalk_id: chalk_ir::RawId) -> T { - T::from_intern_id(salsa::InternId::from(chalk_id.index)) -} -fn to_chalk(salsa_id: T) -> chalk_ir::RawId { - chalk_ir::RawId { index: salsa_id.as_intern_id().as_u32() } -} - -impl From for TraitId { - fn from(trait_id: chalk_ir::TraitId) -> Self { - from_chalk(trait_id.0) - } -} - -impl From for chalk_ir::TraitId { - fn from(trait_id: TraitId) -> Self { - chalk_ir::TraitId(to_chalk(trait_id)) - } -} - #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct TypeAliasId(salsa::InternId); impl_intern_key!(TypeAliasId); @@ -374,37 +355,14 @@ impl MacroCallId { } } -/// This exists just for chalk, because chalk doesn't differentiate between -/// enums and structs. +/// 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)] pub struct TypeCtorId(salsa::InternId); impl_intern_key!(TypeCtorId); -impl From for TypeCtorId { - fn from(struct_id: chalk_ir::StructId) -> Self { - from_chalk(struct_id.0) - } -} - -impl From for chalk_ir::StructId { - fn from(adt_id: TypeCtorId) -> Self { - chalk_ir::StructId(to_chalk(adt_id)) - } -} - -/// This exists just for chalk, because our ImplIds are only unique per module. +/// This exists just for Chalk, because our ImplIds are only unique per module. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct GlobalImplId(salsa::InternId); impl_intern_key!(GlobalImplId); - -impl From for GlobalImplId { - fn from(impl_id: chalk_ir::ImplId) -> Self { - from_chalk(impl_id.0) - } -} - -impl From for chalk_ir::ImplId { - fn from(impl_id: GlobalImplId) -> Self { - chalk_ir::ImplId(to_chalk(impl_id)) - } -} -- cgit v1.2.3