@@ -96,6 +96,7 @@ pub(super) fn lower(
9696 expander,
9797 name_to_pat_grouping : Default :: default ( ) ,
9898 is_lowering_inside_or_pat : false ,
99+ is_lowering_assignee_expr : false ,
99100 }
100101 . collect ( params, body)
101102}
@@ -109,6 +110,7 @@ struct ExprCollector<'a> {
109110 // a poor-mans union-find?
110111 name_to_pat_grouping : FxHashMap < Name , Vec < PatId > > ,
111112 is_lowering_inside_or_pat : bool ,
113+ is_lowering_assignee_expr : bool ,
112114}
113115
114116impl ExprCollector < ' _ > {
@@ -283,7 +285,10 @@ impl ExprCollector<'_> {
283285 } else {
284286 Box :: default ( )
285287 } ;
286- self . alloc_expr ( Expr :: Call { callee, args } , syntax_ptr)
288+ self . alloc_expr (
289+ Expr :: Call { callee, args, is_assignee_expr : self . is_lowering_assignee_expr } ,
290+ syntax_ptr,
291+ )
287292 }
288293 ast:: Expr :: MethodCallExpr ( e) => {
289294 let receiver = self . collect_expr_opt ( e. receiver ( ) ) ;
@@ -359,6 +364,7 @@ impl ExprCollector<'_> {
359364 ast:: Expr :: RecordExpr ( e) => {
360365 let path =
361366 e. path ( ) . and_then ( |path| self . expander . parse_path ( self . db , path) ) . map ( Box :: new) ;
367+ let is_assignee_expr = self . is_lowering_assignee_expr ;
362368 let record_lit = if let Some ( nfl) = e. record_expr_field_list ( ) {
363369 let fields = nfl
364370 . fields ( )
@@ -378,9 +384,16 @@ impl ExprCollector<'_> {
378384 } )
379385 . collect ( ) ;
380386 let spread = nfl. spread ( ) . map ( |s| self . collect_expr ( s) ) ;
381- Expr :: RecordLit { path, fields, spread }
387+ let ellipsis = nfl. dotdot_token ( ) . is_some ( ) ;
388+ Expr :: RecordLit { path, fields, spread, ellipsis, is_assignee_expr }
382389 } else {
383- Expr :: RecordLit { path, fields : Box :: default ( ) , spread : None }
390+ Expr :: RecordLit {
391+ path,
392+ fields : Box :: default ( ) ,
393+ spread : None ,
394+ ellipsis : false ,
395+ is_assignee_expr,
396+ }
384397 } ;
385398
386399 self . alloc_expr ( record_lit, syntax_ptr)
@@ -458,14 +471,21 @@ impl ExprCollector<'_> {
458471 )
459472 }
460473 ast:: Expr :: BinExpr ( e) => {
474+ let op = e. op_kind ( ) ;
475+ if let Some ( ast:: BinaryOp :: Assignment { op : None } ) = op {
476+ self . is_lowering_assignee_expr = true ;
477+ }
461478 let lhs = self . collect_expr_opt ( e. lhs ( ) ) ;
479+ self . is_lowering_assignee_expr = false ;
462480 let rhs = self . collect_expr_opt ( e. rhs ( ) ) ;
463- let op = e. op_kind ( ) ;
464481 self . alloc_expr ( Expr :: BinaryOp { lhs, rhs, op } , syntax_ptr)
465482 }
466483 ast:: Expr :: TupleExpr ( e) => {
467484 let exprs = e. fields ( ) . map ( |expr| self . collect_expr ( expr) ) . collect ( ) ;
468- self . alloc_expr ( Expr :: Tuple { exprs } , syntax_ptr)
485+ self . alloc_expr (
486+ Expr :: Tuple { exprs, is_assignee_expr : self . is_lowering_assignee_expr } ,
487+ syntax_ptr,
488+ )
469489 }
470490 ast:: Expr :: BoxExpr ( e) => {
471491 let expr = self . collect_expr_opt ( e. expr ( ) ) ;
@@ -477,8 +497,14 @@ impl ExprCollector<'_> {
477497
478498 match kind {
479499 ArrayExprKind :: ElementList ( e) => {
480- let exprs = e. map ( |expr| self . collect_expr ( expr) ) . collect ( ) ;
481- self . alloc_expr ( Expr :: Array ( Array :: ElementList ( exprs) ) , syntax_ptr)
500+ let elements = e. map ( |expr| self . collect_expr ( expr) ) . collect ( ) ;
501+ self . alloc_expr (
502+ Expr :: Array ( Array :: ElementList {
503+ elements,
504+ is_assignee_expr : self . is_lowering_assignee_expr ,
505+ } ) ,
506+ syntax_ptr,
507+ )
482508 }
483509 ArrayExprKind :: Repeat { initializer, repeat } => {
484510 let initializer = self . collect_expr_opt ( initializer) ;
0 commit comments