mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Implement rudimentary type inference for unary operators
This commit is contained in:
parent
ab46f8abf1
commit
a2b6d3da30
4 changed files with 72 additions and 5 deletions
|
@ -182,7 +182,7 @@ pub enum Expr {
|
|||
},
|
||||
UnaryOp {
|
||||
expr: ExprId,
|
||||
op: Option<UnaryOp>,
|
||||
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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue