aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/body
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/body')
-rw-r--r--crates/ra_hir_def/src/body/lower.rs32
1 files changed, 22 insertions, 10 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index 754924050..5323af097 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -494,45 +494,57 @@ where
494 fn collect_block_items(&mut self, block: &ast::Block) { 494 fn collect_block_items(&mut self, block: &ast::Block) {
495 let container = ContainerId::DefWithBodyId(self.def); 495 let container = ContainerId::DefWithBodyId(self.def);
496 for item in block.items() { 496 for item in block.items() {
497 let def: ModuleDefId = match item { 497 let (def, name): (ModuleDefId, Option<ast::Name>) = match item {
498 ast::ModuleItem::FnDef(def) => { 498 ast::ModuleItem::FnDef(def) => {
499 let ast_id = self.expander.ast_id(&def); 499 let ast_id = self.expander.ast_id(&def);
500 FunctionLoc { container: container.into(), ast_id }.intern(self.db).into() 500 (
501 FunctionLoc { container: container.into(), ast_id }.intern(self.db).into(),
502 def.name(),
503 )
501 } 504 }
502 ast::ModuleItem::TypeAliasDef(def) => { 505 ast::ModuleItem::TypeAliasDef(def) => {
503 let ast_id = self.expander.ast_id(&def); 506 let ast_id = self.expander.ast_id(&def);
504 TypeAliasLoc { container: container.into(), ast_id }.intern(self.db).into() 507 (
508 TypeAliasLoc { container: container.into(), ast_id }.intern(self.db).into(),
509 def.name(),
510 )
505 } 511 }
506 ast::ModuleItem::ConstDef(def) => { 512 ast::ModuleItem::ConstDef(def) => {
507 let ast_id = self.expander.ast_id(&def); 513 let ast_id = self.expander.ast_id(&def);
508 ConstLoc { container: container.into(), ast_id }.intern(self.db).into() 514 (
515 ConstLoc { container: container.into(), ast_id }.intern(self.db).into(),
516 def.name(),
517 )
509 } 518 }
510 ast::ModuleItem::StaticDef(def) => { 519 ast::ModuleItem::StaticDef(def) => {
511 let ast_id = self.expander.ast_id(&def); 520 let ast_id = self.expander.ast_id(&def);
512 StaticLoc { container, ast_id }.intern(self.db).into() 521 (StaticLoc { container, ast_id }.intern(self.db).into(), def.name())
513 } 522 }
514 ast::ModuleItem::StructDef(def) => { 523 ast::ModuleItem::StructDef(def) => {
515 let ast_id = self.expander.ast_id(&def); 524 let ast_id = self.expander.ast_id(&def);
516 StructLoc { container, ast_id }.intern(self.db).into() 525 (StructLoc { container, ast_id }.intern(self.db).into(), def.name())
517 } 526 }
518 ast::ModuleItem::EnumDef(def) => { 527 ast::ModuleItem::EnumDef(def) => {
519 let ast_id = self.expander.ast_id(&def); 528 let ast_id = self.expander.ast_id(&def);
520 EnumLoc { container, ast_id }.intern(self.db).into() 529 (EnumLoc { container, ast_id }.intern(self.db).into(), def.name())
521 } 530 }
522 ast::ModuleItem::UnionDef(def) => { 531 ast::ModuleItem::UnionDef(def) => {
523 let ast_id = self.expander.ast_id(&def); 532 let ast_id = self.expander.ast_id(&def);
524 UnionLoc { container, ast_id }.intern(self.db).into() 533 (UnionLoc { container, ast_id }.intern(self.db).into(), def.name())
525 } 534 }
526 ast::ModuleItem::TraitDef(def) => { 535 ast::ModuleItem::TraitDef(def) => {
527 let ast_id = self.expander.ast_id(&def); 536 let ast_id = self.expander.ast_id(&def);
528 TraitLoc { container, ast_id }.intern(self.db).into() 537 (TraitLoc { container, ast_id }.intern(self.db).into(), def.name())
529 } 538 }
530 ast::ModuleItem::ImplBlock(_) 539 ast::ModuleItem::ImplBlock(_)
531 | ast::ModuleItem::UseItem(_) 540 | ast::ModuleItem::UseItem(_)
532 | ast::ModuleItem::ExternCrateItem(_) 541 | ast::ModuleItem::ExternCrateItem(_)
533 | ast::ModuleItem::Module(_) => continue, 542 | ast::ModuleItem::Module(_) => continue,
534 }; 543 };
535 self.body.item_scope.define_def(def) 544 self.body.item_scope.define_def(def);
545 if let Some(name) = name {
546 self.body.item_scope.push_res(name.as_name(), def.into());
547 }
536 } 548 }
537 } 549 }
538 550