diff options
author | Aleksey Kladov <[email protected]> | 2020-07-31 14:46:12 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-31 14:51:01 +0100 |
commit | d4d986c7f850e1f535bb4c22e3a7f7fba5483628 (patch) | |
tree | 08477af01b6c828249c88db126b2f86e0e6899bd /crates/ra_hir_def/src/body | |
parent | a7ca6583fbce6f1bddce7b31ad5bb1fc0665b616 (diff) |
Item is a Stmt
Diffstat (limited to 'crates/ra_hir_def/src/body')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 827ced4ad..5816bf566 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -10,7 +10,7 @@ use hir_expand::{ | |||
10 | use ra_arena::Arena; | 10 | use ra_arena::Arena; |
11 | use ra_syntax::{ | 11 | use ra_syntax::{ |
12 | ast::{ | 12 | ast::{ |
13 | self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, ModuleItemOwner, NameOwner, | 13 | self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, NameOwner, |
14 | SlicePatComponents, | 14 | SlicePatComponents, |
15 | }, | 15 | }, |
16 | AstNode, AstPtr, | 16 | AstNode, AstPtr, |
@@ -601,14 +601,20 @@ impl ExprCollector<'_> { | |||
601 | self.collect_block_items(&block); | 601 | self.collect_block_items(&block); |
602 | let statements = block | 602 | let statements = block |
603 | .statements() | 603 | .statements() |
604 | .map(|s| match s { | 604 | .filter_map(|s| { |
605 | ast::Stmt::LetStmt(stmt) => { | 605 | let stmt = match s { |
606 | let pat = self.collect_pat_opt(stmt.pat()); | 606 | ast::Stmt::LetStmt(stmt) => { |
607 | let type_ref = stmt.ty().map(|it| TypeRef::from_ast(&self.ctx(), it)); | 607 | let pat = self.collect_pat_opt(stmt.pat()); |
608 | let initializer = stmt.initializer().map(|e| self.collect_expr(e)); | 608 | let type_ref = stmt.ty().map(|it| TypeRef::from_ast(&self.ctx(), it)); |
609 | Statement::Let { pat, type_ref, initializer } | 609 | let initializer = stmt.initializer().map(|e| self.collect_expr(e)); |
610 | } | 610 | Statement::Let { pat, type_ref, initializer } |
611 | ast::Stmt::ExprStmt(stmt) => Statement::Expr(self.collect_expr_opt(stmt.expr())), | 611 | } |
612 | ast::Stmt::ExprStmt(stmt) => { | ||
613 | Statement::Expr(self.collect_expr_opt(stmt.expr())) | ||
614 | } | ||
615 | ast::Stmt::Item(_) => return None, | ||
616 | }; | ||
617 | Some(stmt) | ||
612 | }) | 618 | }) |
613 | .collect(); | 619 | .collect(); |
614 | let tail = block.expr().map(|e| self.collect_expr(e)); | 620 | let tail = block.expr().map(|e| self.collect_expr(e)); |
@@ -620,7 +626,11 @@ impl ExprCollector<'_> { | |||
620 | let container = ContainerId::DefWithBodyId(self.def); | 626 | let container = ContainerId::DefWithBodyId(self.def); |
621 | 627 | ||
622 | let items = block | 628 | let items = block |
623 | .items() | 629 | .statements() |
630 | .filter_map(|stmt| match stmt { | ||
631 | ast::Stmt::Item(it) => Some(it), | ||
632 | ast::Stmt::LetStmt(_) | ast::Stmt::ExprStmt(_) => None, | ||
633 | }) | ||
624 | .filter_map(|item| { | 634 | .filter_map(|item| { |
625 | let (def, name): (ModuleDefId, Option<ast::Name>) = match item { | 635 | let (def, name): (ModuleDefId, Option<ast::Name>) = match item { |
626 | ast::Item::Fn(def) => { | 636 | ast::Item::Fn(def) => { |