diff options
Diffstat (limited to 'crates/ra_hir_def/src/body')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 17efa10e2..853e17bae 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, FunctionLoc, Intern, | 28 | ConstLoc, ContainerId, DefWithBodyId, EnumLoc, FunctionLoc, Intern, ModuleDefId, StaticLoc, |
29 | StructLoc, TraitLoc, TypeAliasLoc, UnionLoc, | ||
29 | }; | 30 | }; |
30 | 31 | ||
31 | pub(super) fn lower( | 32 | pub(super) fn lower( |
@@ -492,14 +493,45 @@ where | |||
492 | fn collect_block_items(&mut self, block: &ast::Block) { | 493 | fn collect_block_items(&mut self, block: &ast::Block) { |
493 | let container = ContainerId::DefWithBodyId(self.def); | 494 | let container = ContainerId::DefWithBodyId(self.def); |
494 | for item in block.items() { | 495 | for item in block.items() { |
495 | match item { | 496 | let def: ModuleDefId = match item { |
496 | ast::ModuleItem::FnDef(def) => { | 497 | ast::ModuleItem::FnDef(def) => { |
497 | let ast_id = self.expander.ast_id(&def); | 498 | let ast_id = self.expander.ast_id(&def); |
498 | self.body.defs.push(FunctionLoc { container, ast_id }.intern(self.db).into()) | 499 | FunctionLoc { container: container.into(), ast_id }.intern(self.db).into() |
499 | } | 500 | } |
500 | // FIXME: handle other items | 501 | ast::ModuleItem::TypeAliasDef(def) => { |
501 | _ => (), | 502 | let ast_id = self.expander.ast_id(&def); |
502 | } | 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 | } | ||
513 | ast::ModuleItem::StructDef(def) => { | ||
514 | let ast_id = self.expander.ast_id(&def); | ||
515 | StructLoc { container, ast_id }.intern(self.db).into() | ||
516 | } | ||
517 | ast::ModuleItem::EnumDef(def) => { | ||
518 | let ast_id = self.expander.ast_id(&def); | ||
519 | EnumLoc { container, ast_id }.intern(self.db).into() | ||
520 | } | ||
521 | ast::ModuleItem::UnionDef(def) => { | ||
522 | let ast_id = self.expander.ast_id(&def); | ||
523 | UnionLoc { container, ast_id }.intern(self.db).into() | ||
524 | } | ||
525 | ast::ModuleItem::TraitDef(def) => { | ||
526 | let ast_id = self.expander.ast_id(&def); | ||
527 | TraitLoc { container, ast_id }.intern(self.db).into() | ||
528 | } | ||
529 | ast::ModuleItem::ImplBlock(_) | ||
530 | | ast::ModuleItem::UseItem(_) | ||
531 | | ast::ModuleItem::ExternCrateItem(_) | ||
532 | | ast::ModuleItem::Module(_) => continue, | ||
533 | }; | ||
534 | self.body.defs.push(def) | ||
503 | } | 535 | } |
504 | } | 536 | } |
505 | 537 | ||