diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 16 | ||||
-rw-r--r-- | crates/ra_hir_def/src/impls.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 37 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir_def/src/traits.rs | 8 |
5 files changed, 35 insertions, 42 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index b8d48a500..669666989 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -12,8 +12,8 @@ use hir_def::{ | |||
12 | builtin_type::BuiltinType, | 12 | builtin_type::BuiltinType, |
13 | traits::TraitData, | 13 | traits::TraitData, |
14 | type_ref::{Mutability, TypeRef}, | 14 | type_ref::{Mutability, TypeRef}, |
15 | AssocItemId, CrateModuleId, FunctionContainerId, HasModule, ImplId, LocalEnumVariantId, | 15 | AssocItemId, ContainerId, CrateModuleId, HasModule, ImplId, LocalEnumVariantId, |
16 | LocalStructFieldId, Lookup, ModuleId, TypeAliasContainerId, UnionId, | 16 | LocalStructFieldId, Lookup, ModuleId, UnionId, |
17 | }; | 17 | }; |
18 | use hir_expand::{ | 18 | use hir_expand::{ |
19 | diagnostics::DiagnosticSink, | 19 | diagnostics::DiagnosticSink, |
@@ -697,9 +697,9 @@ impl Function { | |||
697 | 697 | ||
698 | pub fn container(self, db: &impl DefDatabase) -> Option<Container> { | 698 | pub fn container(self, db: &impl DefDatabase) -> Option<Container> { |
699 | match self.id.lookup(db).container { | 699 | match self.id.lookup(db).container { |
700 | FunctionContainerId::TraitId(it) => Some(Container::Trait(it.into())), | 700 | ContainerId::TraitId(it) => Some(Container::Trait(it.into())), |
701 | FunctionContainerId::ImplId(it) => Some(Container::ImplBlock(it.into())), | 701 | ContainerId::ImplId(it) => Some(Container::ImplBlock(it.into())), |
702 | FunctionContainerId::ModuleId(_) => None, | 702 | ContainerId::ModuleId(_) => None, |
703 | } | 703 | } |
704 | } | 704 | } |
705 | 705 | ||
@@ -979,9 +979,9 @@ impl TypeAlias { | |||
979 | 979 | ||
980 | pub fn container(self, db: &impl DefDatabase) -> Option<Container> { | 980 | pub fn container(self, db: &impl DefDatabase) -> Option<Container> { |
981 | match self.id.lookup(db).container { | 981 | match self.id.lookup(db).container { |
982 | TypeAliasContainerId::TraitId(it) => Some(Container::Trait(it.into())), | 982 | ContainerId::TraitId(it) => Some(Container::Trait(it.into())), |
983 | TypeAliasContainerId::ImplId(it) => Some(Container::ImplBlock(it.into())), | 983 | ContainerId::ImplId(it) => Some(Container::ImplBlock(it.into())), |
984 | TypeAliasContainerId::ModuleId(_) => None, | 984 | ContainerId::ModuleId(_) => None, |
985 | } | 985 | } |
986 | } | 986 | } |
987 | 987 | ||
diff --git a/crates/ra_hir_def/src/impls.rs b/crates/ra_hir_def/src/impls.rs index 703e4d503..574086ac7 100644 --- a/crates/ra_hir_def/src/impls.rs +++ b/crates/ra_hir_def/src/impls.rs | |||
@@ -9,8 +9,8 @@ use hir_expand::AstId; | |||
9 | use ra_syntax::ast; | 9 | use ra_syntax::ast; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | db::DefDatabase2, type_ref::TypeRef, AssocItemId, AstItemDef, ConstId, FunctionContainerId, | 12 | db::DefDatabase2, type_ref::TypeRef, AssocItemId, AstItemDef, ConstId, ContainerId, |
13 | FunctionLoc, ImplId, Intern, LocationCtx, TypeAliasContainerId, TypeAliasLoc, | 13 | FunctionLoc, ImplId, Intern, LocationCtx, TypeAliasLoc, |
14 | }; | 14 | }; |
15 | 15 | ||
16 | #[derive(Debug, Clone, PartialEq, Eq)] | 16 | #[derive(Debug, Clone, PartialEq, Eq)] |
@@ -37,7 +37,7 @@ impl ImplData { | |||
37 | .map(|item_node| match item_node { | 37 | .map(|item_node| match item_node { |
38 | ast::ImplItem::FnDef(it) => { | 38 | ast::ImplItem::FnDef(it) => { |
39 | let def = FunctionLoc { | 39 | let def = FunctionLoc { |
40 | container: FunctionContainerId::ImplId(id), | 40 | container: ContainerId::ImplId(id), |
41 | ast_id: AstId::new(src.file_id, items.ast_id(&it)), | 41 | ast_id: AstId::new(src.file_id, items.ast_id(&it)), |
42 | } | 42 | } |
43 | .intern(db); | 43 | .intern(db); |
@@ -48,7 +48,7 @@ impl ImplData { | |||
48 | } | 48 | } |
49 | ast::ImplItem::TypeAliasDef(it) => { | 49 | ast::ImplItem::TypeAliasDef(it) => { |
50 | let def = TypeAliasLoc { | 50 | let def = TypeAliasLoc { |
51 | container: TypeAliasContainerId::ImplId(id), | 51 | container: ContainerId::ImplId(id), |
52 | ast_id: AstId::new(src.file_id, items.ast_id(&it)), | 52 | ast_id: AstId::new(src.file_id, items.ast_id(&it)), |
53 | } | 53 | } |
54 | .intern(db); | 54 | .intern(db); |
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 6052370b4..da6506fcd 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -201,7 +201,7 @@ impl_intern_key!(FunctionId); | |||
201 | 201 | ||
202 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 202 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
203 | pub struct FunctionLoc { | 203 | pub struct FunctionLoc { |
204 | pub container: FunctionContainerId, | 204 | pub container: ContainerId, |
205 | pub ast_id: AstId<ast::FnDef>, | 205 | pub ast_id: AstId<ast::FnDef>, |
206 | } | 206 | } |
207 | 207 | ||
@@ -220,13 +220,6 @@ impl Lookup for FunctionId { | |||
220 | } | 220 | } |
221 | 221 | ||
222 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 222 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
223 | pub enum FunctionContainerId { | ||
224 | ModuleId(ModuleId), | ||
225 | ImplId(ImplId), | ||
226 | TraitId(TraitId), | ||
227 | } | ||
228 | |||
229 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
230 | pub struct StructOrUnionId(salsa::InternId); | 223 | pub struct StructOrUnionId(salsa::InternId); |
231 | impl_intern_key!(StructOrUnionId); | 224 | impl_intern_key!(StructOrUnionId); |
232 | impl AstItemDef<ast::StructDef> for StructOrUnionId { | 225 | impl AstItemDef<ast::StructDef> for StructOrUnionId { |
@@ -335,7 +328,7 @@ impl_intern_key!(TypeAliasId); | |||
335 | 328 | ||
336 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 329 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
337 | pub struct TypeAliasLoc { | 330 | pub struct TypeAliasLoc { |
338 | pub container: TypeAliasContainerId, | 331 | pub container: ContainerId, |
339 | pub ast_id: AstId<ast::TypeAliasDef>, | 332 | pub ast_id: AstId<ast::TypeAliasDef>, |
340 | } | 333 | } |
341 | 334 | ||
@@ -354,13 +347,6 @@ impl Lookup for TypeAliasId { | |||
354 | } | 347 | } |
355 | 348 | ||
356 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 349 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
357 | pub enum TypeAliasContainerId { | ||
358 | ModuleId(ModuleId), | ||
359 | ImplId(ImplId), | ||
360 | TraitId(TraitId), | ||
361 | } | ||
362 | |||
363 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
364 | pub struct ImplId(salsa::InternId); | 350 | pub struct ImplId(salsa::InternId); |
365 | impl_intern_key!(ImplId); | 351 | impl_intern_key!(ImplId); |
366 | impl AstItemDef<ast::ImplBlock> for ImplId { | 352 | impl AstItemDef<ast::ImplBlock> for ImplId { |
@@ -391,6 +377,13 @@ macro_rules! impl_froms { | |||
391 | } | 377 | } |
392 | } | 378 | } |
393 | 379 | ||
380 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
381 | pub enum ContainerId { | ||
382 | ModuleId(ModuleId), | ||
383 | ImplId(ImplId), | ||
384 | TraitId(TraitId), | ||
385 | } | ||
386 | |||
394 | /// A Data Type | 387 | /// A Data Type |
395 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | 388 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
396 | pub enum AdtId { | 389 | pub enum AdtId { |
@@ -488,9 +481,9 @@ pub trait HasModule { | |||
488 | impl HasModule for FunctionLoc { | 481 | impl HasModule for FunctionLoc { |
489 | fn module(&self, db: &impl db::DefDatabase2) -> ModuleId { | 482 | fn module(&self, db: &impl db::DefDatabase2) -> ModuleId { |
490 | match self.container { | 483 | match self.container { |
491 | FunctionContainerId::ModuleId(it) => it, | 484 | ContainerId::ModuleId(it) => it, |
492 | FunctionContainerId::ImplId(it) => it.module(db), | 485 | ContainerId::ImplId(it) => it.module(db), |
493 | FunctionContainerId::TraitId(it) => it.module(db), | 486 | ContainerId::TraitId(it) => it.module(db), |
494 | } | 487 | } |
495 | } | 488 | } |
496 | } | 489 | } |
@@ -498,9 +491,9 @@ impl HasModule for FunctionLoc { | |||
498 | impl HasModule for TypeAliasLoc { | 491 | impl HasModule for TypeAliasLoc { |
499 | fn module(&self, db: &impl db::DefDatabase2) -> ModuleId { | 492 | fn module(&self, db: &impl db::DefDatabase2) -> ModuleId { |
500 | match self.container { | 493 | match self.container { |
501 | TypeAliasContainerId::ModuleId(it) => it, | 494 | ContainerId::ModuleId(it) => it, |
502 | TypeAliasContainerId::ImplId(it) => it.module(db), | 495 | ContainerId::ImplId(it) => it.module(db), |
503 | TypeAliasContainerId::TraitId(it) => it.module(db), | 496 | ContainerId::TraitId(it) => it.module(db), |
504 | } | 497 | } |
505 | } | 498 | } |
506 | } | 499 | } |
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 060185b61..71e01279d 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -19,9 +19,9 @@ use crate::{ | |||
19 | per_ns::PerNs, raw, CrateDefMap, ModuleData, Resolution, ResolveMode, | 19 | per_ns::PerNs, raw, CrateDefMap, ModuleData, Resolution, ResolveMode, |
20 | }, | 20 | }, |
21 | path::{Path, PathKind}, | 21 | path::{Path, PathKind}, |
22 | AdtId, AstId, AstItemDef, ConstId, CrateModuleId, EnumId, EnumVariantId, FunctionContainerId, | 22 | AdtId, AstId, AstItemDef, ConstId, ContainerId, CrateModuleId, EnumId, EnumVariantId, |
23 | FunctionLoc, ImplId, Intern, LocationCtx, ModuleDefId, ModuleId, StaticId, StructId, | 23 | FunctionLoc, ImplId, Intern, LocationCtx, ModuleDefId, ModuleId, StaticId, StructId, |
24 | StructOrUnionId, TraitId, TypeAliasContainerId, TypeAliasLoc, UnionId, | 24 | StructOrUnionId, TraitId, TypeAliasLoc, UnionId, |
25 | }; | 25 | }; |
26 | 26 | ||
27 | pub(super) fn collect_defs(db: &impl DefDatabase2, mut def_map: CrateDefMap) -> CrateDefMap { | 27 | pub(super) fn collect_defs(db: &impl DefDatabase2, mut def_map: CrateDefMap) -> CrateDefMap { |
@@ -674,7 +674,7 @@ where | |||
674 | let def: PerNs = match def.kind { | 674 | let def: PerNs = match def.kind { |
675 | raw::DefKind::Function(ast_id) => { | 675 | raw::DefKind::Function(ast_id) => { |
676 | let def = FunctionLoc { | 676 | let def = FunctionLoc { |
677 | container: FunctionContainerId::ModuleId(module), | 677 | container: ContainerId::ModuleId(module), |
678 | ast_id: AstId::new(self.file_id, ast_id), | 678 | ast_id: AstId::new(self.file_id, ast_id), |
679 | } | 679 | } |
680 | .intern(self.def_collector.db); | 680 | .intern(self.def_collector.db); |
@@ -699,7 +699,7 @@ where | |||
699 | raw::DefKind::Trait(ast_id) => PerNs::types(TraitId::from_ast_id(ctx, ast_id).into()), | 699 | raw::DefKind::Trait(ast_id) => PerNs::types(TraitId::from_ast_id(ctx, ast_id).into()), |
700 | raw::DefKind::TypeAlias(ast_id) => { | 700 | raw::DefKind::TypeAlias(ast_id) => { |
701 | let def = TypeAliasLoc { | 701 | let def = TypeAliasLoc { |
702 | container: TypeAliasContainerId::ModuleId(module), | 702 | container: ContainerId::ModuleId(module), |
703 | ast_id: AstId::new(self.file_id, ast_id), | 703 | ast_id: AstId::new(self.file_id, ast_id), |
704 | } | 704 | } |
705 | .intern(self.def_collector.db); | 705 | .intern(self.def_collector.db); |
diff --git a/crates/ra_hir_def/src/traits.rs b/crates/ra_hir_def/src/traits.rs index 228524a57..bb61e852a 100644 --- a/crates/ra_hir_def/src/traits.rs +++ b/crates/ra_hir_def/src/traits.rs | |||
@@ -11,8 +11,8 @@ use ra_syntax::ast::{self, NameOwner}; | |||
11 | use rustc_hash::FxHashMap; | 11 | use rustc_hash::FxHashMap; |
12 | 12 | ||
13 | use crate::{ | 13 | use crate::{ |
14 | db::DefDatabase2, AssocItemId, AstItemDef, ConstId, FunctionContainerId, FunctionLoc, Intern, | 14 | db::DefDatabase2, AssocItemId, AstItemDef, ConstId, ContainerId, FunctionLoc, Intern, |
15 | LocationCtx, ModuleDefId, ModuleId, TraitId, TypeAliasContainerId, TypeAliasLoc, | 15 | LocationCtx, ModuleDefId, ModuleId, TraitId, TypeAliasLoc, |
16 | }; | 16 | }; |
17 | 17 | ||
18 | #[derive(Debug, Clone, PartialEq, Eq)] | 18 | #[derive(Debug, Clone, PartialEq, Eq)] |
@@ -35,14 +35,14 @@ impl TraitData { | |||
35 | .impl_items() | 35 | .impl_items() |
36 | .map(|item_node| match item_node { | 36 | .map(|item_node| match item_node { |
37 | ast::ImplItem::FnDef(it) => FunctionLoc { | 37 | ast::ImplItem::FnDef(it) => FunctionLoc { |
38 | container: FunctionContainerId::TraitId(tr), | 38 | container: ContainerId::TraitId(tr), |
39 | ast_id: AstId::new(src.file_id, ast_id_map.ast_id(&it)), | 39 | ast_id: AstId::new(src.file_id, ast_id_map.ast_id(&it)), |
40 | } | 40 | } |
41 | .intern(db) | 41 | .intern(db) |
42 | .into(), | 42 | .into(), |
43 | ast::ImplItem::ConstDef(it) => ConstId::from_ast(ctx, &it).into(), | 43 | ast::ImplItem::ConstDef(it) => ConstId::from_ast(ctx, &it).into(), |
44 | ast::ImplItem::TypeAliasDef(it) => TypeAliasLoc { | 44 | ast::ImplItem::TypeAliasDef(it) => TypeAliasLoc { |
45 | container: TypeAliasContainerId::TraitId(tr), | 45 | container: ContainerId::TraitId(tr), |
46 | ast_id: AstId::new(src.file_id, ast_id_map.ast_id(&it)), | 46 | ast_id: AstId::new(src.file_id, ast_id_map.ast_id(&it)), |
47 | } | 47 | } |
48 | .intern(db) | 48 | .intern(db) |