From 5ac9f5cdc7a88dcb9545d2e150780c8edee83b06 Mon Sep 17 00:00:00 2001 From: Unreal Hoang Date: Sat, 20 Jul 2019 19:35:49 +0900 Subject: add await expr to ast --- crates/ra_hir/src/expr.rs | 8 ++++++++ crates/ra_hir/src/ty/infer.rs | 3 +++ 2 files changed, 11 insertions(+) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 66cb9633b..7e3e0a07d 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs @@ -220,6 +220,9 @@ pub enum Expr { expr: ExprId, name: Name, }, + Await { + expr: ExprId, + }, Try { expr: ExprId, }, @@ -359,6 +362,7 @@ impl Expr { f(*rhs); } Expr::Field { expr, .. } + | Expr::Await { expr } | Expr::Try { expr } | Expr::Cast { expr, .. } | Expr::Ref { expr, .. } @@ -729,6 +733,10 @@ where }; self.alloc_expr(Expr::Field { expr, name }, syntax_ptr) } + ast::ExprKind::AwaitExpr(e) => { + let expr = self.collect_expr_opt(e.expr()); + self.alloc_expr(Expr::Await { expr }, syntax_ptr) + } ast::ExprKind::TryExpr(e) => { let expr = self.collect_expr_opt(e.expr()); self.alloc_expr(Expr::Try { expr }, syntax_ptr) diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 0e030576d..6eae595a9 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs @@ -1114,6 +1114,9 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { .unwrap_or(Ty::Unknown); self.insert_type_vars(ty) } + Expr::Await { .. } => { + Ty::Unknown + } Expr::Try { expr } => { let inner_ty = self.infer_expr(*expr, &Expectation::none()); let ty = match self.resolve_ops_try_ok() { -- cgit v1.2.3