aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-31 16:09:31 +0100
committerGitHub <[email protected]>2020-07-31 16:09:31 +0100
commit7325283c6977e078513b5b21aa173775e2b22e12 (patch)
tree7be8b4fbc2e7470bf7891d81b3812eb572bb0d1c /crates/ra_hir_def/src
parentad239f6197bda31f7a9b904b5ccb25c93cbc701a (diff)
parent633aace41108b74fe6c93c5ab04272067db033f9 (diff)
Merge #5624
5624: Finalize expressions grammar 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.rs24
1 files changed, 18 insertions, 6 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index 5816bf566..99d723402 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -224,9 +224,22 @@ impl ExprCollector<'_> {
224 self.alloc_expr(Expr::Unsafe { body }, syntax_ptr) 224 self.alloc_expr(Expr::Unsafe { body }, syntax_ptr)
225 } 225 }
226 // FIXME: we need to record these effects somewhere... 226 // FIXME: we need to record these effects somewhere...
227 ast::Effect::Async(_) | ast::Effect::Label(_) => { 227 ast::Effect::Label(label) => match e.block_expr() {
228 self.collect_block_opt(e.block_expr()) 228 Some(block) => {
229 } 229 let res = self.collect_block(block);
230 match &mut self.body.exprs[res] {
231 Expr::Block { label: block_label, .. } => {
232 *block_label =
233 label.lifetime_token().map(|t| Name::new_lifetime(&t))
234 }
235 _ => unreachable!(),
236 }
237 res
238 }
239 None => self.missing_expr(),
240 },
241 // FIXME: we need to record these effects somewhere...
242 ast::Effect::Async(_) => self.collect_block_opt(e.block_expr()),
230 }, 243 },
231 ast::Expr::BlockExpr(e) => self.collect_block(e), 244 ast::Expr::BlockExpr(e) => self.collect_block(e),
232 ast::Expr::LoopExpr(e) => { 245 ast::Expr::LoopExpr(e) => {
@@ -460,7 +473,7 @@ impl ExprCollector<'_> {
460 self.alloc_expr(Expr::Missing, syntax_ptr) 473 self.alloc_expr(Expr::Missing, syntax_ptr)
461 } 474 }
462 } 475 }
463 ast::Expr::LambdaExpr(e) => { 476 ast::Expr::ClosureExpr(e) => {
464 let mut args = Vec::new(); 477 let mut args = Vec::new();
465 let mut arg_types = Vec::new(); 478 let mut arg_types = Vec::new();
466 if let Some(pl) = e.param_list() { 479 if let Some(pl) = e.param_list() {
@@ -618,8 +631,7 @@ impl ExprCollector<'_> {
618 }) 631 })
619 .collect(); 632 .collect();
620 let tail = block.expr().map(|e| self.collect_expr(e)); 633 let tail = block.expr().map(|e| self.collect_expr(e));
621 let label = block.label().and_then(|l| l.lifetime_token()).map(|t| Name::new_lifetime(&t)); 634 self.alloc_expr(Expr::Block { statements, tail, label: None }, syntax_node_ptr)
622 self.alloc_expr(Expr::Block { statements, tail, label }, syntax_node_ptr)
623 } 635 }
624 636
625 fn collect_block_items(&mut self, block: &ast::BlockExpr) { 637 fn collect_block_items(&mut self, block: &ast::BlockExpr) {