File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
compiler/rustc_ast_lowering/src Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -860,14 +860,28 @@ impl<'hir> LoweringContext<'_, 'hir> {
860
860
} )
861
861
}
862
862
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; }`.
864
865
fn lower_expr_assign (
865
866
& mut self ,
866
867
lhs : & Expr ,
867
868
rhs : & Expr ,
868
869
eq_sign_span : Span ,
869
870
whole_span : Span ,
870
871
) -> 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
+
871
885
let mut assignments = Vec :: new ( ) ;
872
886
873
887
// The LHS becomes a pattern: `(lhs1, lhs2)`
You can’t perform that action at this time.
0 commit comments