aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-20 11:22:55 +0000
committerAleksey Kladov <[email protected]>2019-12-20 11:22:55 +0000
commitfe1b160dcfdeb3f582ccae1440c9580ade0beb39 (patch)
tree574aaf7ee9a3b57e39bf1129a6d20c1f4b330fb7
parentac5a3f611b05dbedd286169539335ae9f0fbb7b0 (diff)
Support for nested statics, consts and type aliases
-rw-r--r--crates/ra_hir_def/src/body/lower.rs15
-rw-r--r--crates/ra_hir_def/src/lib.rs6
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs2
3 files changed, 18 insertions, 5 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index 0d3f946df..b61f924b7 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -25,7 +25,8 @@ use crate::{
25 path::GenericArgs, 25 path::GenericArgs,
26 path::Path, 26 path::Path,
27 type_ref::{Mutability, TypeRef}, 27 type_ref::{Mutability, TypeRef},
28 ContainerId, DefWithBodyId, EnumLoc, FunctionLoc, Intern, ModuleDefId, StructLoc, UnionLoc, 28 ConstLoc, ContainerId, DefWithBodyId, EnumLoc, FunctionLoc, Intern, ModuleDefId, StaticLoc,
29 StructLoc, TypeAliasLoc, UnionLoc,
29}; 30};
30 31
31pub(super) fn lower( 32pub(super) fn lower(
@@ -497,6 +498,18 @@ where
497 let ast_id = self.expander.ast_id(&def); 498 let ast_id = self.expander.ast_id(&def);
498 FunctionLoc { container: container.into(), ast_id }.intern(self.db).into() 499 FunctionLoc { container: container.into(), ast_id }.intern(self.db).into()
499 } 500 }
501 ast::ModuleItem::TypeAliasDef(def) => {
502 let ast_id = self.expander.ast_id(&def);
503 TypeAliasLoc { container: container.into(), ast_id }.intern(self.db).into()
504 }
505 ast::ModuleItem::ConstDef(def) => {
506 let ast_id = self.expander.ast_id(&def);
507 ConstLoc { container: container.into(), ast_id }.intern(self.db).into()
508 }
509 ast::ModuleItem::StaticDef(def) => {
510 let ast_id = self.expander.ast_id(&def);
511 StaticLoc { container, ast_id }.intern(self.db).into()
512 }
500 ast::ModuleItem::StructDef(def) => { 513 ast::ModuleItem::StructDef(def) => {
501 let ast_id = self.expander.ast_id(&def); 514 let ast_id = self.expander.ast_id(&def);
502 StructLoc { container, ast_id }.intern(self.db).into() 515 StructLoc { container, ast_id }.intern(self.db).into()
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index a82de7dec..9b192b597 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -211,7 +211,7 @@ impl_intern_key!(StaticId);
211 211
212#[derive(Debug, Clone, PartialEq, Eq, Hash)] 212#[derive(Debug, Clone, PartialEq, Eq, Hash)]
213pub struct StaticLoc { 213pub struct StaticLoc {
214 pub container: ModuleId, 214 pub container: ContainerId,
215 pub ast_id: AstId<ast::StaticDef>, 215 pub ast_id: AstId<ast::StaticDef>,
216} 216}
217 217
@@ -558,7 +558,7 @@ impl HasModule for GenericDefId {
558} 558}
559 559
560impl HasModule for StaticLoc { 560impl HasModule for StaticLoc {
561 fn module(&self, _db: &impl db::DefDatabase) -> ModuleId { 561 fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
562 self.container 562 self.container.module(db)
563 } 563 }
564} 564}
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 1b39af61e..74c3d4670 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -796,7 +796,7 @@ where
796 PerNs::values(def.into()) 796 PerNs::values(def.into())
797 } 797 }
798 raw::DefKind::Static(ast_id) => { 798 raw::DefKind::Static(ast_id) => {
799 let def = StaticLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } 799 let def = StaticLoc { container, ast_id: AstId::new(self.file_id, ast_id) }
800 .intern(self.def_collector.db); 800 .intern(self.def_collector.db);
801 801
802 PerNs::values(def.into()) 802 PerNs::values(def.into())