mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Implement tuple inference
This commit is contained in:
parent
6efda8f6ce
commit
6e73cc89b6
2 changed files with 20 additions and 1 deletions
|
@ -183,6 +183,9 @@ pub enum Expr {
|
|||
arg_types: Vec<Option<TypeRef>>,
|
||||
body: ExprId,
|
||||
},
|
||||
Tuple {
|
||||
exprs: Vec<ExprId>,
|
||||
},
|
||||
}
|
||||
|
||||
pub use ra_syntax::ast::PrefixOp as UnaryOp;
|
||||
|
@ -297,6 +300,11 @@ impl Expr {
|
|||
| Expr::UnaryOp { expr, .. } => {
|
||||
f(*expr);
|
||||
}
|
||||
Expr::Tuple { exprs } => {
|
||||
for expr in exprs {
|
||||
f(*expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -621,11 +629,14 @@ impl ExprCollector {
|
|||
let op = e.op();
|
||||
self.alloc_expr(Expr::BinaryOp { lhs, rhs, op }, syntax_ptr)
|
||||
}
|
||||
ast::ExprKind::TupleExpr(e) => {
|
||||
let exprs = e.exprs().map(|expr| self.collect_expr(expr)).collect();
|
||||
self.alloc_expr(Expr::Tuple { exprs }, syntax_ptr)
|
||||
}
|
||||
|
||||
// TODO implement HIR for these:
|
||||
ast::ExprKind::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
|
||||
ast::ExprKind::IndexExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
|
||||
ast::ExprKind::TupleExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
|
||||
ast::ExprKind::ArrayExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
|
||||
ast::ExprKind::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
|
||||
ast::ExprKind::Literal(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue