diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-02 10:57:45 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-02 10:57:45 +0100 |
commit | 75bc0249463b72971200e482d69dad88d4e76ae3 (patch) | |
tree | cf12a19a548f77af306bd8eeb4ba6a74175e1790 /crates/ra_hir_def/src/body | |
parent | 235728319fb545670e49db996e9c2cd94b8b34eb (diff) | |
parent | b73dbbfbf2cad646eb3f8e3342a1c390a874dc53 (diff) |
Merge #4257
4257: ast::EffectExpr r=matklad a=matklad
closes #4230
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/body')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index f06cc115b..58b3d10d8 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -203,10 +203,16 @@ impl ExprCollector<'_> { | |||
203 | 203 | ||
204 | self.alloc_expr(Expr::If { condition, then_branch, else_branch }, syntax_ptr) | 204 | self.alloc_expr(Expr::If { condition, then_branch, else_branch }, syntax_ptr) |
205 | } | 205 | } |
206 | ast::Expr::TryBlockExpr(e) => { | 206 | ast::Expr::EffectExpr(e) => match e.effect() { |
207 | let body = self.collect_block_opt(e.body()); | 207 | ast::Effect::Try(_) => { |
208 | self.alloc_expr(Expr::TryBlock { body }, syntax_ptr) | 208 | let body = self.collect_block_opt(e.block_expr()); |
209 | } | 209 | self.alloc_expr(Expr::TryBlock { body }, syntax_ptr) |
210 | } | ||
211 | // FIXME: we need to record these effects somewhere... | ||
212 | ast::Effect::Async(_) | ast::Effect::Label(_) | ast::Effect::Unsafe(_) => { | ||
213 | self.collect_block_opt(e.block_expr()) | ||
214 | } | ||
215 | }, | ||
210 | ast::Expr::BlockExpr(e) => self.collect_block(e), | 216 | ast::Expr::BlockExpr(e) => self.collect_block(e), |
211 | ast::Expr::LoopExpr(e) => { | 217 | ast::Expr::LoopExpr(e) => { |
212 | let body = self.collect_block_opt(e.loop_body()); | 218 | let body = self.collect_block_opt(e.loop_body()); |
@@ -494,12 +500,8 @@ impl ExprCollector<'_> { | |||
494 | } | 500 | } |
495 | } | 501 | } |
496 | 502 | ||
497 | fn collect_block(&mut self, expr: ast::BlockExpr) -> ExprId { | 503 | fn collect_block(&mut self, block: ast::BlockExpr) -> ExprId { |
498 | let syntax_node_ptr = AstPtr::new(&expr.clone().into()); | 504 | let syntax_node_ptr = AstPtr::new(&block.clone().into()); |
499 | let block = match expr.block() { | ||
500 | Some(block) => block, | ||
501 | None => return self.alloc_expr(Expr::Missing, syntax_node_ptr), | ||
502 | }; | ||
503 | self.collect_block_items(&block); | 505 | self.collect_block_items(&block); |
504 | let statements = block | 506 | let statements = block |
505 | .statements() | 507 | .statements() |
@@ -517,7 +519,7 @@ impl ExprCollector<'_> { | |||
517 | self.alloc_expr(Expr::Block { statements, tail }, syntax_node_ptr) | 519 | self.alloc_expr(Expr::Block { statements, tail }, syntax_node_ptr) |
518 | } | 520 | } |
519 | 521 | ||
520 | fn collect_block_items(&mut self, block: &ast::Block) { | 522 | fn collect_block_items(&mut self, block: &ast::BlockExpr) { |
521 | let container = ContainerId::DefWithBodyId(self.def); | 523 | let container = ContainerId::DefWithBodyId(self.def); |
522 | for item in block.items() { | 524 | for item in block.items() { |
523 | let (def, name): (ModuleDefId, Option<ast::Name>) = match item { | 525 | let (def, name): (ModuleDefId, Option<ast::Name>) = match item { |