diff options
author | Seivan Heidari <[email protected]> | 2019-11-21 00:11:41 +0000 |
---|---|---|
committer | Seivan Heidari <[email protected]> | 2019-11-21 00:11:41 +0000 |
commit | 358a1bcd708c622836723e5201b6de77cc9ff327 (patch) | |
tree | aeff9c96a6059fa2b02e7c87ec88753bc7993d8d /crates/ra_hir_def/src/nameres | |
parent | 1e2d090ab8a9bda18f148b894b7948eb05b976e6 (diff) | |
parent | 612a72fc4ea4376920f2a7da7b3c334227c1716c (diff) |
Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer into feature/themes
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 33 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/raw.rs | 2 |
2 files changed, 27 insertions, 8 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 8f426b097..aae3dcadf 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, FunctionId, ImplId, | 22 | AdtId, AstId, AstItemDef, ConstLoc, ContainerId, CrateModuleId, EnumId, EnumVariantId, |
23 | LocationCtx, ModuleDefId, ModuleId, StaticId, StructId, StructOrUnionId, TraitId, TypeAliasId, | 23 | FunctionLoc, ImplId, Intern, LocationCtx, ModuleDefId, ModuleId, StaticId, StructId, |
24 | 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 { |
@@ -673,8 +673,13 @@ where | |||
673 | let name = def.name.clone(); | 673 | let name = def.name.clone(); |
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 f = FunctionId::from_ast_id(ctx, ast_id); | 676 | let def = FunctionLoc { |
677 | PerNs::values(f.into()) | 677 | container: ContainerId::ModuleId(module), |
678 | ast_id: AstId::new(self.file_id, ast_id), | ||
679 | } | ||
680 | .intern(self.def_collector.db); | ||
681 | |||
682 | PerNs::values(def.into()) | ||
678 | } | 683 | } |
679 | raw::DefKind::Struct(ast_id) => { | 684 | raw::DefKind::Struct(ast_id) => { |
680 | let id = StructOrUnionId::from_ast_id(ctx, ast_id).into(); | 685 | let id = StructOrUnionId::from_ast_id(ctx, ast_id).into(); |
@@ -687,13 +692,27 @@ where | |||
687 | PerNs::both(u, u) | 692 | PerNs::both(u, u) |
688 | } | 693 | } |
689 | raw::DefKind::Enum(ast_id) => PerNs::types(EnumId::from_ast_id(ctx, ast_id).into()), | 694 | raw::DefKind::Enum(ast_id) => PerNs::types(EnumId::from_ast_id(ctx, ast_id).into()), |
690 | raw::DefKind::Const(ast_id) => PerNs::values(ConstId::from_ast_id(ctx, ast_id).into()), | 695 | raw::DefKind::Const(ast_id) => { |
696 | let def = ConstLoc { | ||
697 | container: ContainerId::ModuleId(module), | ||
698 | ast_id: AstId::new(self.file_id, ast_id), | ||
699 | } | ||
700 | .intern(self.def_collector.db); | ||
701 | |||
702 | PerNs::values(def.into()) | ||
703 | } | ||
691 | raw::DefKind::Static(ast_id) => { | 704 | raw::DefKind::Static(ast_id) => { |
692 | PerNs::values(StaticId::from_ast_id(ctx, ast_id).into()) | 705 | PerNs::values(StaticId::from_ast_id(ctx, ast_id).into()) |
693 | } | 706 | } |
694 | raw::DefKind::Trait(ast_id) => PerNs::types(TraitId::from_ast_id(ctx, ast_id).into()), | 707 | raw::DefKind::Trait(ast_id) => PerNs::types(TraitId::from_ast_id(ctx, ast_id).into()), |
695 | raw::DefKind::TypeAlias(ast_id) => { | 708 | raw::DefKind::TypeAlias(ast_id) => { |
696 | PerNs::types(TypeAliasId::from_ast_id(ctx, ast_id).into()) | 709 | let def = TypeAliasLoc { |
710 | container: ContainerId::ModuleId(module), | ||
711 | ast_id: AstId::new(self.file_id, ast_id), | ||
712 | } | ||
713 | .intern(self.def_collector.db); | ||
714 | |||
715 | PerNs::types(def.into()) | ||
697 | } | 716 | } |
698 | }; | 717 | }; |
699 | let resolution = Resolution { def, import: None }; | 718 | let resolution = Resolution { def, import: None }; |
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index a0a2c7273..7c68fd638 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs | |||
@@ -327,7 +327,7 @@ impl RawItemsCollector { | |||
327 | 327 | ||
328 | let mut buf = Vec::new(); | 328 | let mut buf = Vec::new(); |
329 | Path::expand_use_item( | 329 | Path::expand_use_item( |
330 | Source { ast: use_item, file_id: self.file_id }, | 330 | Source { value: use_item, file_id: self.file_id }, |
331 | &self.hygiene, | 331 | &self.hygiene, |
332 | |path, use_tree, is_glob, alias| { | 332 | |path, use_tree, is_glob, alias| { |
333 | let import_data = ImportData { | 333 | let import_data = ImportData { |