diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-31 14:54:19 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-31 14:54:19 +0100 |
commit | ad239f6197bda31f7a9b904b5ccb25c93cbc701a (patch) | |
tree | 5e4b244c62c61824dbb63246aa9943e3b2398131 /crates/ra_hir_def/src | |
parent | 3407d6f8a430627be333c32cb4cef02c0c8d11e3 (diff) | |
parent | d4d986c7f850e1f535bb4c22e3a7f7fba5483628 (diff) |
Merge #5623
5623: Item is a Stmt r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src')
-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) => { |