From a2b6d3da30020421c97100d7c8699a3b4f8cd6fb Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Mon, 14 Jan 2019 23:15:16 +0100 Subject: Implement rudimentary type inference for unary operators --- crates/ra_hir/src/expr.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir/src/expr.rs') diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 4e8dc0c54..663338844 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs @@ -182,7 +182,7 @@ pub enum Expr { }, UnaryOp { expr: ExprId, - op: Option, + op: UnaryOp, }, BinaryOp { lhs: ExprId, @@ -612,8 +612,11 @@ impl ExprCollector { } ast::ExprKind::PrefixExpr(e) => { let expr = self.collect_expr_opt(e.expr()); - let op = e.op(); - self.alloc_expr(Expr::UnaryOp { expr, op }, syntax_ptr) + if let Some(op) = e.op() { + self.alloc_expr(Expr::UnaryOp { expr, op }, syntax_ptr) + } else { + self.alloc_expr(Expr::Missing, syntax_ptr) + } } ast::ExprKind::LambdaExpr(e) => { let mut args = Vec::new(); -- cgit v1.2.3