diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/db.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir/src/ids.rs | 26 | ||||
-rw-r--r-- | crates/ra_hir/src/lib.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir/src/ty.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits.rs | 11 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits/chalk.rs | 18 |
6 files changed, 33 insertions, 41 deletions
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 3ae5df8d5..a9dab2d25 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -5,7 +5,6 @@ use std::sync::Arc; | |||
5 | use ra_db::salsa; | 5 | use ra_db::salsa; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | ids, | ||
9 | ty::{ | 8 | ty::{ |
10 | method_resolution::CrateImplBlocks, | 9 | method_resolution::CrateImplBlocks, |
11 | traits::{AssocTyValue, Impl}, | 10 | traits::{AssocTyValue, Impl}, |
@@ -71,11 +70,14 @@ pub trait HirDatabase: DefDatabase { | |||
71 | 70 | ||
72 | // Interned IDs for Chalk integration | 71 | // Interned IDs for Chalk integration |
73 | #[salsa::interned] | 72 | #[salsa::interned] |
74 | fn intern_type_ctor(&self, type_ctor: TypeCtor) -> ids::TypeCtorId; | 73 | fn intern_type_ctor(&self, type_ctor: TypeCtor) -> crate::ty::TypeCtorId; |
75 | #[salsa::interned] | 74 | #[salsa::interned] |
76 | fn intern_chalk_impl(&self, impl_: Impl) -> ids::GlobalImplId; | 75 | fn intern_chalk_impl(&self, impl_: Impl) -> crate::ty::traits::GlobalImplId; |
77 | #[salsa::interned] | 76 | #[salsa::interned] |
78 | fn intern_assoc_ty_value(&self, assoc_ty_value: AssocTyValue) -> ids::AssocTyValueId; | 77 | fn intern_assoc_ty_value( |
78 | &self, | ||
79 | assoc_ty_value: AssocTyValue, | ||
80 | ) -> crate::ty::traits::AssocTyValueId; | ||
79 | 81 | ||
80 | #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] | 82 | #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] |
81 | fn associated_ty_data( | 83 | fn associated_ty_data( |
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs deleted file mode 100644 index 67de8b243..000000000 --- a/crates/ra_hir/src/ids.rs +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | //! hir makes heavy use of ids: integer (u32) handlers to various things. You | ||
2 | //! can think of id as a pointer (but without a lifetime) or a file descriptor | ||
3 | //! (but for hir objects). | ||
4 | //! | ||
5 | //! This module defines a bunch of ids we are using. The most important ones are | ||
6 | //! probably `HirFileId` and `DefId`. | ||
7 | |||
8 | use ra_db::{impl_intern_key, salsa}; | ||
9 | |||
10 | /// This exists just for Chalk, because Chalk just has a single `StructId` where | ||
11 | /// we have different kinds of ADTs, primitive types and special type | ||
12 | /// constructors like tuples and function pointers. | ||
13 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
14 | pub struct TypeCtorId(salsa::InternId); | ||
15 | impl_intern_key!(TypeCtorId); | ||
16 | |||
17 | /// This exists just for Chalk, because our ImplIds are only unique per module. | ||
18 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
19 | pub struct GlobalImplId(salsa::InternId); | ||
20 | impl_intern_key!(GlobalImplId); | ||
21 | |||
22 | /// This exists just for Chalk, because it needs a unique ID for each associated | ||
23 | /// type value in an impl (even synthetic ones). | ||
24 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
25 | pub struct AssocTyValueId(salsa::InternId); | ||
26 | impl_intern_key!(AssocTyValueId); | ||
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 239798bcc..8c589c728 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -31,7 +31,6 @@ pub mod debug; | |||
31 | pub mod db; | 31 | pub mod db; |
32 | pub mod source_binder; | 32 | pub mod source_binder; |
33 | 33 | ||
34 | mod ids; | ||
35 | mod ty; | 34 | mod ty; |
36 | mod impl_block; | 35 | mod impl_block; |
37 | mod expr; | 36 | mod expr; |
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 95b8df181..309bd2727 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -18,6 +18,7 @@ use std::sync::Arc; | |||
18 | use std::{fmt, iter, mem}; | 18 | use std::{fmt, iter, mem}; |
19 | 19 | ||
20 | use hir_def::{generics::GenericParams, AdtId}; | 20 | use hir_def::{generics::GenericParams, AdtId}; |
21 | use ra_db::{impl_intern_key, salsa}; | ||
21 | 22 | ||
22 | use crate::{ | 23 | use crate::{ |
23 | db::HirDatabase, expr::ExprId, util::make_mut_slice, Adt, Crate, DefWithBody, FloatTy, | 24 | db::HirDatabase, expr::ExprId, util::make_mut_slice, Adt, Crate, DefWithBody, FloatTy, |
@@ -114,6 +115,13 @@ pub enum TypeCtor { | |||
114 | Closure { def: DefWithBody, expr: ExprId }, | 115 | Closure { def: DefWithBody, expr: ExprId }, |
115 | } | 116 | } |
116 | 117 | ||
118 | /// This exists just for Chalk, because Chalk just has a single `StructId` where | ||
119 | /// we have different kinds of ADTs, primitive types and special type | ||
120 | /// constructors like tuples and function pointers. | ||
121 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
122 | pub struct TypeCtorId(salsa::InternId); | ||
123 | impl_intern_key!(TypeCtorId); | ||
124 | |||
117 | impl TypeCtor { | 125 | impl TypeCtor { |
118 | pub fn num_ty_params(self, db: &impl HirDatabase) -> usize { | 126 | pub fn num_ty_params(self, db: &impl HirDatabase) -> usize { |
119 | match self { | 127 | match self { |
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}; | |||
3 | 3 | ||
4 | use chalk_ir::{cast::Cast, family::ChalkIr}; | 4 | use chalk_ir::{cast::Cast, family::ChalkIr}; |
5 | use log::debug; | 5 | use log::debug; |
6 | use ra_db::salsa; | 6 | use ra_db::{impl_intern_key, salsa}; |
7 | use ra_prof::profile; | 7 | use ra_prof::profile; |
8 | use rustc_hash::FxHashSet; | 8 | use rustc_hash::FxHashSet; |
9 | 9 | ||
@@ -304,6 +304,10 @@ pub enum Impl { | |||
304 | /// Closure types implement the Fn traits synthetically. | 304 | /// Closure types implement the Fn traits synthetically. |
305 | ClosureFnTraitImpl(ClosureFnTraitImplData), | 305 | ClosureFnTraitImpl(ClosureFnTraitImplData), |
306 | } | 306 | } |
307 | /// This exists just for Chalk, because our ImplIds are only unique per module. | ||
308 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
309 | pub struct GlobalImplId(salsa::InternId); | ||
310 | impl_intern_key!(GlobalImplId); | ||
307 | 311 | ||
308 | /// An associated type value. Usually this comes from a `type` declaration | 312 | /// An associated type value. Usually this comes from a `type` declaration |
309 | /// inside an impl block, but for built-in impls we have to synthesize it. | 313 | /// inside an impl block, but for built-in impls we have to synthesize it. |
@@ -315,3 +319,8 @@ pub enum AssocTyValue { | |||
315 | /// The output type of the Fn trait implementation. | 319 | /// The output type of the Fn trait implementation. |
316 | ClosureFnTraitImplOutput(ClosureFnTraitImplData), | 320 | ClosureFnTraitImplOutput(ClosureFnTraitImplData), |
317 | } | 321 | } |
322 | /// This exists just for Chalk, because it needs a unique ID for each associated | ||
323 | /// type value in an impl (even synthetic ones). | ||
324 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
325 | pub struct AssocTyValueId(salsa::InternId); | ||
326 | 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<T: InternKey>(salsa_id: T) -> chalk_ir::RawId { | |||
847 | chalk_ir::RawId { index: salsa_id.as_intern_id().as_u32() } | 847 | chalk_ir::RawId { index: salsa_id.as_intern_id().as_u32() } |
848 | } | 848 | } |
849 | 849 | ||
850 | impl From<chalk_ir::StructId> for crate::ids::TypeCtorId { | 850 | impl From<chalk_ir::StructId> for crate::ty::TypeCtorId { |
851 | fn from(struct_id: chalk_ir::StructId) -> Self { | 851 | fn from(struct_id: chalk_ir::StructId) -> Self { |
852 | id_from_chalk(struct_id.0) | 852 | id_from_chalk(struct_id.0) |
853 | } | 853 | } |
854 | } | 854 | } |
855 | 855 | ||
856 | impl From<crate::ids::TypeCtorId> for chalk_ir::StructId { | 856 | impl From<crate::ty::TypeCtorId> for chalk_ir::StructId { |
857 | fn from(type_ctor_id: crate::ids::TypeCtorId) -> Self { | 857 | fn from(type_ctor_id: crate::ty::TypeCtorId) -> Self { |
858 | chalk_ir::StructId(id_to_chalk(type_ctor_id)) | 858 | chalk_ir::StructId(id_to_chalk(type_ctor_id)) |
859 | } | 859 | } |
860 | } | 860 | } |
861 | 861 | ||
862 | impl From<chalk_ir::ImplId> for crate::ids::GlobalImplId { | 862 | impl From<chalk_ir::ImplId> for crate::ty::traits::GlobalImplId { |
863 | fn from(impl_id: chalk_ir::ImplId) -> Self { | 863 | fn from(impl_id: chalk_ir::ImplId) -> Self { |
864 | id_from_chalk(impl_id.0) | 864 | id_from_chalk(impl_id.0) |
865 | } | 865 | } |
866 | } | 866 | } |
867 | 867 | ||
868 | impl From<crate::ids::GlobalImplId> for chalk_ir::ImplId { | 868 | impl From<crate::ty::traits::GlobalImplId> for chalk_ir::ImplId { |
869 | fn from(impl_id: crate::ids::GlobalImplId) -> Self { | 869 | fn from(impl_id: crate::ty::traits::GlobalImplId) -> Self { |
870 | chalk_ir::ImplId(id_to_chalk(impl_id)) | 870 | chalk_ir::ImplId(id_to_chalk(impl_id)) |
871 | } | 871 | } |
872 | } | 872 | } |
873 | 873 | ||
874 | impl From<chalk_rust_ir::AssociatedTyValueId> for crate::ids::AssocTyValueId { | 874 | impl From<chalk_rust_ir::AssociatedTyValueId> for crate::ty::traits::AssocTyValueId { |
875 | fn from(id: chalk_rust_ir::AssociatedTyValueId) -> Self { | 875 | fn from(id: chalk_rust_ir::AssociatedTyValueId) -> Self { |
876 | id_from_chalk(id.0) | 876 | id_from_chalk(id.0) |
877 | } | 877 | } |
878 | } | 878 | } |
879 | 879 | ||
880 | impl From<crate::ids::AssocTyValueId> for chalk_rust_ir::AssociatedTyValueId { | 880 | impl From<crate::ty::traits::AssocTyValueId> for chalk_rust_ir::AssociatedTyValueId { |
881 | fn from(assoc_ty_value_id: crate::ids::AssocTyValueId) -> Self { | 881 | fn from(assoc_ty_value_id: crate::ty::traits::AssocTyValueId) -> Self { |
882 | chalk_rust_ir::AssociatedTyValueId(id_to_chalk(assoc_ty_value_id)) | 882 | chalk_rust_ir::AssociatedTyValueId(id_to_chalk(assoc_ty_value_id)) |
883 | } | 883 | } |
884 | } | 884 | } |