Skip to content

Commit 5e39caa

Browse files
committed
Disallow .. rest in struct on LHS of an assignment
1 parent a6562bd commit 5e39caa

File tree

1 file changed

+5
-3
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+5
-3
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,8 +871,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
871871
) -> hir::ExprKind<'hir> {
872872
// Return early in case of an ordinary assignment.
873873
match lhs.kind {
874-
ExprKind::Array(..) | ExprKind::Call(..) | ExprKind::Struct(..) | ExprKind::Tup(..) => {
875-
}
874+
ExprKind::Array(..)
875+
| ExprKind::Call(..)
876+
| ExprKind::Struct(_, _, None)
877+
| ExprKind::Tup(..) => {}
876878
_ => {
877879
return hir::ExprKind::Assign(
878880
self.lower_expr(lhs),
@@ -959,7 +961,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
959961
}
960962
// structs:
961963
// FIXME: support `..` here, requires changes to the parser
962-
ExprKind::Struct(path, fields, _rest) => {
964+
ExprKind::Struct(path, fields, None) => {
963965
let field_pats = self.arena.alloc_from_iter(fields.iter().map(|f| {
964966
let pat = self.destructure_assign(&f.expr, eq_sign_span, assignments);
965967
hir::FieldPat {

0 commit comments

Comments
 (0)