@@ -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 ( )
@@ -379,9 +385,15 @@ impl ExprCollector<'_> {
379385 . collect ( ) ;
380386 let spread = nfl. spread ( ) . map ( |s| self . collect_expr ( s) ) ;
381387 let ellipsis = nfl. dotdot_token ( ) . is_some ( ) ;
382- Expr :: RecordLit { path, fields, spread, ellipsis }
388+ Expr :: RecordLit { path, fields, spread, ellipsis, is_assignee_expr }
383389 } else {
384- Expr :: RecordLit { path, fields : Box :: default ( ) , spread : None , ellipsis : false }
390+ Expr :: RecordLit {
391+ path,
392+ fields : Box :: default ( ) ,
393+ spread : None ,
394+ ellipsis : false ,
395+ is_assignee_expr,
396+ }
385397 } ;
386398
387399 self . alloc_expr ( record_lit, syntax_ptr)
@@ -459,14 +471,21 @@ impl ExprCollector<'_> {
459471 )
460472 }
461473 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+ }
462478 let lhs = self . collect_expr_opt ( e. lhs ( ) ) ;
479+ self . is_lowering_assignee_expr = false ;
463480 let rhs = self . collect_expr_opt ( e. rhs ( ) ) ;
464- let op = e. op_kind ( ) ;
465481 self . alloc_expr ( Expr :: BinaryOp { lhs, rhs, op } , syntax_ptr)
466482 }
467483 ast:: Expr :: TupleExpr ( e) => {
468484 let exprs = e. fields ( ) . map ( |expr| self . collect_expr ( expr) ) . collect ( ) ;
469- 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+ )
470489 }
471490 ast:: Expr :: BoxExpr ( e) => {
472491 let expr = self . collect_expr_opt ( e. expr ( ) ) ;
@@ -478,8 +497,14 @@ impl ExprCollector<'_> {
478497
479498 match kind {
480499 ArrayExprKind :: ElementList ( e) => {
481- let exprs = e. map ( |expr| self . collect_expr ( expr) ) . collect ( ) ;
482- 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+ )
483508 }
484509 ArrayExprKind :: Repeat { initializer, repeat } => {
485510 let initializer = self . collect_expr_opt ( initializer) ;
0 commit comments