Add ellipsis to HIR RecordLit

This commit is contained in:
Ryo Yoshida 2022-07-22 18:12:21 +09:00
parent 977e12a0bd
commit fb063d360c
No known key found for this signature in database
GPG Key ID: E25698A930586171
4 changed files with 6 additions and 4 deletions

View File

@ -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)

View File

@ -138,6 +138,7 @@ pub enum Expr {
path: Option<Box<Path>>,
fields: Box<[RecordLitField]>,
spread: Option<ExprId>,
ellipsis: bool,
},
Field {
expr: ExprId,

View File

@ -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,
};

View File

@ -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);