mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
implement initial type inference for index expressions
This commit is contained in:
parent
b082cd679a
commit
189d879659
3 changed files with 33 additions and 1 deletions
|
@ -245,6 +245,10 @@ pub enum Expr {
|
|||
rhs: ExprId,
|
||||
op: Option<BinaryOp>,
|
||||
},
|
||||
Index {
|
||||
base: ExprId,
|
||||
index: ExprId,
|
||||
},
|
||||
Lambda {
|
||||
args: Vec<PatId>,
|
||||
arg_types: Vec<Option<TypeRef>>,
|
||||
|
@ -399,6 +403,10 @@ impl Expr {
|
|||
f(*lhs);
|
||||
f(*rhs);
|
||||
}
|
||||
Expr::Index { base, index } => {
|
||||
f(*base);
|
||||
f(*index);
|
||||
}
|
||||
Expr::Field { expr, .. }
|
||||
| Expr::Await { expr }
|
||||
| Expr::Try { expr }
|
||||
|
@ -887,10 +895,14 @@ where
|
|||
};
|
||||
self.alloc_expr(Expr::Literal(lit), syntax_ptr)
|
||||
}
|
||||
ast::ExprKind::IndexExpr(e) => {
|
||||
let base = self.collect_expr_opt(e.base());
|
||||
let index = self.collect_expr_opt(e.index());
|
||||
self.alloc_expr(Expr::Index { base, index }, syntax_ptr)
|
||||
}
|
||||
|
||||
// FIXME 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::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
|
||||
ast::ExprKind::MacroCall(e) => {
|
||||
let ast_id = self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue