Add ellipsis
to HIR RecordLit
This commit is contained in:
parent
977e12a0bd
commit
fb063d360c
@ -378,9 +378,10 @@ fn maybe_collect_expr(&mut self, expr: ast::Expr) -> Option<ExprId> {
|
||||
})
|
||||
.collect();
|
||||
let spread = nfl.spread().map(|s| self.collect_expr(s));
|
||||
Expr::RecordLit { path, fields, spread }
|
||||
let ellipsis = nfl.dotdot_token().is_some();
|
||||
Expr::RecordLit { path, fields, spread, ellipsis }
|
||||
} else {
|
||||
Expr::RecordLit { path, fields: Box::default(), spread: None }
|
||||
Expr::RecordLit { path, fields: Box::default(), spread: None, ellipsis: false }
|
||||
};
|
||||
|
||||
self.alloc_expr(record_lit, syntax_ptr)
|
||||
|
@ -138,6 +138,7 @@ pub enum Expr {
|
||||
path: Option<Box<Path>>,
|
||||
fields: Box<[RecordLitField]>,
|
||||
spread: Option<ExprId>,
|
||||
ellipsis: bool,
|
||||
},
|
||||
Field {
|
||||
expr: ExprId,
|
||||
|
@ -305,7 +305,7 @@ pub fn record_literal_missing_fields(
|
||||
expr: &Expr,
|
||||
) -> Option<(VariantId, Vec<LocalFieldId>, /*exhaustive*/ bool)> {
|
||||
let (fields, exhaustive) = match expr {
|
||||
Expr::RecordLit { path: _, fields, spread } => (fields, spread.is_none()),
|
||||
Expr::RecordLit { fields, spread, .. } => (fields, spread.is_none()),
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
|
@ -421,7 +421,7 @@ fn infer_expr_inner(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty {
|
||||
}
|
||||
TyKind::Never.intern(Interner)
|
||||
}
|
||||
Expr::RecordLit { path, fields, spread } => {
|
||||
Expr::RecordLit { path, fields, spread, .. } => {
|
||||
let (ty, def_id) = self.resolve_variant(path.as_deref(), false);
|
||||
if let Some(variant) = def_id {
|
||||
self.write_variant_resolution(tgt_expr.into(), variant);
|
||||
|
Loading…
Reference in New Issue
Block a user