Skip to content

Commit 475cd1e

Browse files
committed
Handle ordinary assignments as before
1 parent 7823897 commit 475cd1e

File tree

1 file changed

+15
-1
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+15
-1
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,14 +860,28 @@ impl<'hir> LoweringContext<'_, 'hir> {
860860
})
861861
}
862862

863-
/// Lower `(a,b) = t` to `{ let (lhs1,lhs2) = t; a = lhs1; b = lhs2; }`.
863+
/// Destructure the LHS of complex assignments.
864+
/// For instance, lower `(a,b) = t` to `{ let (lhs1,lhs2) = t; a = lhs1; b = lhs2; }`.
864865
fn lower_expr_assign(
865866
&mut self,
866867
lhs: &Expr,
867868
rhs: &Expr,
868869
eq_sign_span: Span,
869870
whole_span: Span,
870871
) -> hir::ExprKind<'hir> {
872+
// Return early in case of an ordinary assignment.
873+
match lhs.kind {
874+
ExprKind::Array(..) | ExprKind::Call(..) | ExprKind::Struct(..) | ExprKind::Tup(..) => {
875+
}
876+
_ => {
877+
return hir::ExprKind::Assign(
878+
self.lower_expr(lhs),
879+
self.lower_expr(rhs),
880+
eq_sign_span,
881+
);
882+
}
883+
}
884+
871885
let mut assignments = Vec::new();
872886

873887
// The LHS becomes a pattern: `(lhs1, lhs2)`

0 commit comments

Comments
 (0)