mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Added inference of array length
This commit is contained in:
parent
36f5d99756
commit
2d73c909fe
6 changed files with 62 additions and 5 deletions
|
@ -240,6 +240,7 @@ pub enum Expr {
|
|||
},
|
||||
Array {
|
||||
exprs: Vec<ExprId>,
|
||||
repeat: Option<ExprId>,
|
||||
},
|
||||
Literal(Literal),
|
||||
}
|
||||
|
@ -348,11 +349,20 @@ impl Expr {
|
|||
| Expr::UnaryOp { expr, .. } => {
|
||||
f(*expr);
|
||||
}
|
||||
Expr::Tuple { exprs } | Expr::Array { exprs } => {
|
||||
Expr::Tuple { exprs } => {
|
||||
for expr in exprs {
|
||||
f(*expr);
|
||||
}
|
||||
}
|
||||
Expr::Array { exprs, repeat } => {
|
||||
for expr in exprs {
|
||||
f(*expr);
|
||||
}
|
||||
|
||||
if let Some(expr) = repeat {
|
||||
f(*expr)
|
||||
}
|
||||
}
|
||||
Expr::Literal(_) => {}
|
||||
}
|
||||
}
|
||||
|
@ -725,7 +735,8 @@ impl ExprCollector {
|
|||
}
|
||||
ast::ExprKind::ArrayExpr(e) => {
|
||||
let exprs = e.exprs().map(|expr| self.collect_expr(expr)).collect();
|
||||
self.alloc_expr(Expr::Array { exprs }, syntax_ptr)
|
||||
let repeat = e.repeat().map(|e| self.collect_expr(e));
|
||||
self.alloc_expr(Expr::Array { exprs, repeat }, syntax_ptr)
|
||||
}
|
||||
ast::ExprKind::Literal(e) => {
|
||||
let lit = match e.kind() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue