From 85cd3524e28443836658615fe40599bf10a96943 Mon Sep 17 00:00:00 2001 From: Daiki Ihara Date: Thu, 14 Jan 2021 00:01:50 +0900 Subject: Add support for yiled keyword --- crates/hir_def/src/body/lower.rs | 4 ++++ crates/hir_def/src/expr.rs | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'crates/hir_def/src') 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<'_> { let expr = e.expr().map(|e| self.collect_expr(e)); self.alloc_expr(Expr::Return { expr }, syntax_ptr) } + ast::Expr::YieldExpr(e) => { + let expr = e.expr().map(|e| self.collect_expr(e)); + self.alloc_expr(Expr::Yield { expr }, syntax_ptr) + } ast::Expr::RecordExpr(e) => { let path = e.path().and_then(|path| self.expander.parse_path(path)); 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 { Return { expr: Option, }, + Yield { + expr: Option, + }, RecordLit { path: Option, fields: Vec, @@ -294,7 +297,7 @@ impl Expr { } } Expr::Continue { .. } => {} - Expr::Break { expr, .. } | Expr::Return { expr } => { + Expr::Break { expr, .. } | Expr::Return { expr } | Expr::Yield { expr } => { if let Some(expr) = expr { f(*expr); } -- cgit v1.2.3