diff options
author | Aleksey Kladov <[email protected]> | 2019-12-20 11:20:49 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-20 11:20:49 +0000 |
commit | ac5a3f611b05dbedd286169539335ae9f0fbb7b0 (patch) | |
tree | d3891e65a1f043c9adce655bb88507ade16ac0b9 /crates/ra_hir_def/src/body/lower.rs | |
parent | 94ad07af4bef6a70602e315bf315c6fce95618dd (diff) |
Support for nested ADT
Diffstat (limited to 'crates/ra_hir_def/src/body/lower.rs')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 0103a1aab..0d3f946df 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -25,7 +25,7 @@ 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 | ContainerId, DefWithBodyId, EnumLoc, FunctionLoc, Intern, ModuleDefId, StructLoc, UnionLoc, |
29 | }; | 29 | }; |
30 | 30 | ||
31 | pub(super) fn lower( | 31 | pub(super) fn lower( |
@@ -490,16 +490,28 @@ where | |||
490 | } | 490 | } |
491 | 491 | ||
492 | fn collect_block_items(&mut self, block: &ast::Block) { | 492 | fn collect_block_items(&mut self, block: &ast::Block) { |
493 | let container = ContainerId::DefWithBodyId(self.def).into(); | 493 | let container = ContainerId::DefWithBodyId(self.def); |
494 | for item in block.items() { | 494 | for item in block.items() { |
495 | match item { | 495 | let def: ModuleDefId = match item { |
496 | ast::ModuleItem::FnDef(def) => { | 496 | ast::ModuleItem::FnDef(def) => { |
497 | let ast_id = self.expander.ast_id(&def); | 497 | let ast_id = self.expander.ast_id(&def); |
498 | self.body.defs.push(FunctionLoc { container, ast_id }.intern(self.db).into()) | 498 | FunctionLoc { container: container.into(), ast_id }.intern(self.db).into() |
499 | } | 499 | } |
500 | // FIXME: handle other items | 500 | ast::ModuleItem::StructDef(def) => { |
501 | _ => (), | 501 | let ast_id = self.expander.ast_id(&def); |
502 | } | 502 | StructLoc { container, ast_id }.intern(self.db).into() |
503 | } | ||
504 | ast::ModuleItem::EnumDef(def) => { | ||
505 | let ast_id = self.expander.ast_id(&def); | ||
506 | EnumLoc { container, ast_id }.intern(self.db).into() | ||
507 | } | ||
508 | ast::ModuleItem::UnionDef(def) => { | ||
509 | let ast_id = self.expander.ast_id(&def); | ||
510 | UnionLoc { container, ast_id }.intern(self.db).into() | ||
511 | } | ||
512 | _ => continue, | ||
513 | }; | ||
514 | self.body.defs.push(def) | ||
503 | } | 515 | } |
504 | } | 516 | } |
505 | 517 | ||