Skip to content

Commit 316c711

Browse files
lowrfasterthanlime
authored andcommitted
Add ellipsis to HIR RecordLit
1 parent 918101a commit 316c711

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

src/tools/rust-analyzer/crates/hir-def/src/body/lower.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,10 @@ impl ExprCollector<'_> {
378378
})
379379
.collect();
380380
let spread = nfl.spread().map(|s| self.collect_expr(s));
381-
Expr::RecordLit { path, fields, spread }
381+
let ellipsis = nfl.dotdot_token().is_some();
382+
Expr::RecordLit { path, fields, spread, ellipsis }
382383
} else {
383-
Expr::RecordLit { path, fields: Box::default(), spread: None }
384+
Expr::RecordLit { path, fields: Box::default(), spread: None, ellipsis: false }
384385
};
385386

386387
self.alloc_expr(record_lit, syntax_ptr)

src/tools/rust-analyzer/crates/hir-def/src/expr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ pub enum Expr {
138138
path: Option<Box<Path>>,
139139
fields: Box<[RecordLitField]>,
140140
spread: Option<ExprId>,
141+
ellipsis: bool,
141142
},
142143
Field {
143144
expr: ExprId,

src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ pub fn record_literal_missing_fields(
305305
expr: &Expr,
306306
) -> Option<(VariantId, Vec<LocalFieldId>, /*exhaustive*/ bool)> {
307307
let (fields, exhaustive) = match expr {
308-
Expr::RecordLit { path: _, fields, spread } => (fields, spread.is_none()),
308+
Expr::RecordLit { fields, spread, .. } => (fields, spread.is_none()),
309309
_ => return None,
310310
};
311311

src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ impl<'a> InferenceContext<'a> {
421421
}
422422
TyKind::Never.intern(Interner)
423423
}
424-
Expr::RecordLit { path, fields, spread } => {
424+
Expr::RecordLit { path, fields, spread, .. } => {
425425
let (ty, def_id) = self.resolve_variant(path.as_deref(), false);
426426
if let Some(variant) = def_id {
427427
self.write_variant_resolution(tgt_expr.into(), variant);

0 commit comments

Comments
 (0)