diff options
author | Luca Barbieri <[email protected]> | 2020-04-03 20:12:09 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-04-09 10:50:37 +0100 |
commit | 60f4d7bd8c0ecb9f23557464e824140a2be8f41a (patch) | |
tree | 00aea343b133272e1df072bd7c839fddf07f36f6 /crates/ra_hir_def/src/body | |
parent | 85956932872481cf4813c5e7794d981a9edb4623 (diff) |
Provide more complete AST accessors to support usage in rustc
Diffstat (limited to 'crates/ra_hir_def/src/body')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 8d4b8b0f0..8338414fa 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -482,14 +482,17 @@ 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 | } | 491 | } |
492 | ast::Stmt::ExprStmt(stmt) => Statement::Expr(self.collect_expr_opt(stmt.expr())), | 492 | ast::Stmt::ExprStmt(stmt) => { |
493 | Some(Statement::Expr(self.collect_expr_opt(stmt.expr()))) | ||
494 | } | ||
495 | ast::Stmt::ModuleItem(_) => None, | ||
493 | }) | 496 | }) |
494 | .collect(); | 497 | .collect(); |
495 | let tail = block.expr().map(|e| self.collect_expr(e)); | 498 | let tail = block.expr().map(|e| self.collect_expr(e)); |
@@ -541,6 +544,7 @@ impl ExprCollector<'_> { | |||
541 | let ast_id = self.expander.ast_id(&def); | 544 | let ast_id = self.expander.ast_id(&def); |
542 | (TraitLoc { container, ast_id }.intern(self.db).into(), def.name()) | 545 | (TraitLoc { container, ast_id }.intern(self.db).into(), def.name()) |
543 | } | 546 | } |
547 | ast::ModuleItem::ExternBlock(_) => continue, // FIXME: collect from extern blocks | ||
544 | ast::ModuleItem::ImplDef(_) | 548 | ast::ModuleItem::ImplDef(_) |
545 | | ast::ModuleItem::UseItem(_) | 549 | | ast::ModuleItem::UseItem(_) |
546 | | ast::ModuleItem::ExternCrateItem(_) | 550 | | ast::ModuleItem::ExternCrateItem(_) |