diff options
Diffstat (limited to 'crates/ra_hir_def/src/body/lower.rs')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 8d4b8b0f0..c4a5ec59c 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -482,14 +482,16 @@ impl ExprCollector<'_> { | |||
482 | self.collect_block_items(&block); | 482 | self.collect_block_items(&block); |
483 | let statements = block | 483 | let statements = block |
484 | .statements() | 484 | .statements() |
485 | .map(|s| match s { | 485 | .filter_map(|s| match s { |
486 | ast::Stmt::LetStmt(stmt) => { | 486 | ast::Stmt::LetStmt(stmt) => { |
487 | let pat = self.collect_pat_opt(stmt.pat()); | 487 | let pat = self.collect_pat_opt(stmt.pat()); |
488 | let type_ref = stmt.ascribed_type().map(TypeRef::from_ast); | 488 | let type_ref = stmt.ascribed_type().map(TypeRef::from_ast); |
489 | let initializer = stmt.initializer().map(|e| self.collect_expr(e)); | 489 | let initializer = stmt.initializer().map(|e| self.collect_expr(e)); |
490 | Statement::Let { pat, type_ref, initializer } | 490 | Some(Statement::Let { pat, type_ref, initializer }) |
491 | } | ||
492 | ast::Stmt::ExprStmt(stmt) => { | ||
493 | Some(Statement::Expr(self.collect_expr_opt(stmt.expr()))) | ||
491 | } | 494 | } |
492 | ast::Stmt::ExprStmt(stmt) => Statement::Expr(self.collect_expr_opt(stmt.expr())), | ||
493 | }) | 495 | }) |
494 | .collect(); | 496 | .collect(); |
495 | let tail = block.expr().map(|e| self.collect_expr(e)); | 497 | let tail = block.expr().map(|e| self.collect_expr(e)); |
@@ -541,6 +543,7 @@ impl ExprCollector<'_> { | |||
541 | let ast_id = self.expander.ast_id(&def); | 543 | let ast_id = self.expander.ast_id(&def); |
542 | (TraitLoc { container, ast_id }.intern(self.db).into(), def.name()) | 544 | (TraitLoc { container, ast_id }.intern(self.db).into(), def.name()) |
543 | } | 545 | } |
546 | ast::ModuleItem::ExternBlock(_) => continue, // FIXME: collect from extern blocks | ||
544 | ast::ModuleItem::ImplDef(_) | 547 | ast::ModuleItem::ImplDef(_) |
545 | | ast::ModuleItem::UseItem(_) | 548 | | ast::ModuleItem::UseItem(_) |
546 | | ast::ModuleItem::ExternCrateItem(_) | 549 | | ast::ModuleItem::ExternCrateItem(_) |
@@ -569,7 +572,10 @@ impl ExprCollector<'_> { | |||
569 | let pattern = match &pat { | 572 | let pattern = match &pat { |
570 | ast::Pat::BindPat(bp) => { | 573 | ast::Pat::BindPat(bp) => { |
571 | let name = bp.name().map(|nr| nr.as_name()).unwrap_or_else(Name::missing); | 574 | let name = bp.name().map(|nr| nr.as_name()).unwrap_or_else(Name::missing); |
572 | let annotation = BindingAnnotation::new(bp.is_mutable(), bp.is_ref()); | 575 | let annotation = BindingAnnotation::new( |
576 | bp.mut_kw_token().is_some(), | ||
577 | bp.ref_kw_token().is_some(), | ||
578 | ); | ||
573 | let subpat = bp.pat().map(|subpat| self.collect_pat(subpat)); | 579 | let subpat = bp.pat().map(|subpat| self.collect_pat(subpat)); |
574 | if annotation == BindingAnnotation::Unannotated && subpat.is_none() { | 580 | if annotation == BindingAnnotation::Unannotated && subpat.is_none() { |
575 | // This could also be a single-segment path pattern. To | 581 | // This could also be a single-segment path pattern. To |
@@ -610,7 +616,7 @@ impl ExprCollector<'_> { | |||
610 | } | 616 | } |
611 | ast::Pat::RefPat(p) => { | 617 | ast::Pat::RefPat(p) => { |
612 | let pat = self.collect_pat_opt(p.pat()); | 618 | let pat = self.collect_pat_opt(p.pat()); |
613 | let mutability = Mutability::from_mutable(p.is_mut()); | 619 | let mutability = Mutability::from_mutable(p.mut_kw_token().is_some()); |
614 | Pat::Ref { pat, mutability } | 620 | Pat::Ref { pat, mutability } |
615 | } | 621 | } |
616 | ast::Pat::PathPat(p) => { | 622 | ast::Pat::PathPat(p) => { |