From 9c766db5ff9dad3ca13539c186f40f657380a831 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 24 Nov 2019 14:25:48 +0300 Subject: Remove ids module --- crates/ra_hir/src/ty/traits.rs | 11 ++++++++++- crates/ra_hir/src/ty/traits/chalk.rs | 18 +++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index 45f725438..268fa09e4 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs @@ -3,7 +3,7 @@ use std::sync::{Arc, Mutex}; use chalk_ir::{cast::Cast, family::ChalkIr}; use log::debug; -use ra_db::salsa; +use ra_db::{impl_intern_key, salsa}; use ra_prof::profile; use rustc_hash::FxHashSet; @@ -304,6 +304,10 @@ pub enum Impl { /// Closure types implement the Fn traits synthetically. ClosureFnTraitImpl(ClosureFnTraitImplData), } +/// 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); /// An associated type value. Usually this comes from a `type` declaration /// inside an impl block, but for built-in impls we have to synthesize it. @@ -315,3 +319,8 @@ pub enum AssocTyValue { /// The output type of the Fn trait implementation. ClosureFnTraitImplOutput(ClosureFnTraitImplData), } +/// This exists just for Chalk, because it needs a unique ID for each associated +/// type value in an impl (even synthetic ones). +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct AssocTyValueId(salsa::InternId); +impl_intern_key!(AssocTyValueId); diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs index 53818a5e5..9efdc53c4 100644 --- a/crates/ra_hir/src/ty/traits/chalk.rs +++ b/crates/ra_hir/src/ty/traits/chalk.rs @@ -847,38 +847,38 @@ fn id_to_chalk(salsa_id: T) -> chalk_ir::RawId { chalk_ir::RawId { index: salsa_id.as_intern_id().as_u32() } } -impl From for crate::ids::TypeCtorId { +impl From for crate::ty::TypeCtorId { fn from(struct_id: chalk_ir::StructId) -> Self { id_from_chalk(struct_id.0) } } -impl From for chalk_ir::StructId { - fn from(type_ctor_id: crate::ids::TypeCtorId) -> Self { +impl From for chalk_ir::StructId { + fn from(type_ctor_id: crate::ty::TypeCtorId) -> Self { chalk_ir::StructId(id_to_chalk(type_ctor_id)) } } -impl From for crate::ids::GlobalImplId { +impl From for crate::ty::traits::GlobalImplId { fn from(impl_id: chalk_ir::ImplId) -> Self { id_from_chalk(impl_id.0) } } -impl From for chalk_ir::ImplId { - fn from(impl_id: crate::ids::GlobalImplId) -> Self { +impl From for chalk_ir::ImplId { + fn from(impl_id: crate::ty::traits::GlobalImplId) -> Self { chalk_ir::ImplId(id_to_chalk(impl_id)) } } -impl From for crate::ids::AssocTyValueId { +impl From for crate::ty::traits::AssocTyValueId { fn from(id: chalk_rust_ir::AssociatedTyValueId) -> Self { id_from_chalk(id.0) } } -impl From for chalk_rust_ir::AssociatedTyValueId { - fn from(assoc_ty_value_id: crate::ids::AssocTyValueId) -> Self { +impl From for chalk_rust_ir::AssociatedTyValueId { + fn from(assoc_ty_value_id: crate::ty::traits::AssocTyValueId) -> Self { chalk_rust_ir::AssociatedTyValueId(id_to_chalk(assoc_ty_value_id)) } } -- cgit v1.2.3