aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-15 14:48:21 +0000
committerGitHub <[email protected]>2021-01-15 14:48:21 +0000
commit0c58aa9dc0e24f0fa6a6ee7eb0c35041dedddb0a (patch)
tree863b6e41430b4d9f5c9dcebd443f4acdbe7e0193 /crates/hir_def
parentd6a708b1eae170aee4a323ea6513bc4f2a1a5bbc (diff)
parent138514bea244253f2c0007976921f4475c9d2cd5 (diff)
Merge #7209
7209: Support yield keyword r=Veykril a=sasurau4 Part of #4309 The inference of yield will be implemented at another PR. Co-authored-by: Daiki Ihara <[email protected]>
Diffstat (limited to 'crates/hir_def')
-rw-r--r--crates/hir_def/src/body/lower.rs4
-rw-r--r--crates/hir_def/src/expr.rs5
2 files changed, 8 insertions, 1 deletions
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs
index 27575c537..4ce5e5b72 100644
--- a/crates/hir_def/src/body/lower.rs
+++ b/crates/hir_def/src/body/lower.rs
@@ -386,6 +386,10 @@ impl ExprCollector<'_> {
386 let expr = e.expr().map(|e| self.collect_expr(e)); 386 let expr = e.expr().map(|e| self.collect_expr(e));
387 self.alloc_expr(Expr::Return { expr }, syntax_ptr) 387 self.alloc_expr(Expr::Return { expr }, syntax_ptr)
388 } 388 }
389 ast::Expr::YieldExpr(e) => {
390 let expr = e.expr().map(|e| self.collect_expr(e));
391 self.alloc_expr(Expr::Yield { expr }, syntax_ptr)
392 }
389 ast::Expr::RecordExpr(e) => { 393 ast::Expr::RecordExpr(e) => {
390 let path = e.path().and_then(|path| self.expander.parse_path(path)); 394 let path = e.path().and_then(|path| self.expander.parse_path(path));
391 let mut field_ptrs = Vec::new(); 395 let mut field_ptrs = Vec::new();
diff --git a/crates/hir_def/src/expr.rs b/crates/hir_def/src/expr.rs
index af01d32dc..a293df9f1 100644
--- a/crates/hir_def/src/expr.rs
+++ b/crates/hir_def/src/expr.rs
@@ -99,6 +99,9 @@ pub enum Expr {
99 Return { 99 Return {
100 expr: Option<ExprId>, 100 expr: Option<ExprId>,
101 }, 101 },
102 Yield {
103 expr: Option<ExprId>,
104 },
102 RecordLit { 105 RecordLit {
103 path: Option<Path>, 106 path: Option<Path>,
104 fields: Vec<RecordLitField>, 107 fields: Vec<RecordLitField>,
@@ -294,7 +297,7 @@ impl Expr {
294 } 297 }
295 } 298 }
296 Expr::Continue { .. } => {} 299 Expr::Continue { .. } => {}
297 Expr::Break { expr, .. } | Expr::Return { expr } => { 300 Expr::Break { expr, .. } | Expr::Return { expr } | Expr::Yield { expr } => {
298 if let Some(expr) = expr { 301 if let Some(expr) = expr {
299 f(*expr); 302 f(*expr);
300 } 303 }