@@ -96,6 +96,7 @@ pub(super) fn lower(
96
96
expander,
97
97
name_to_pat_grouping : Default :: default ( ) ,
98
98
is_lowering_inside_or_pat : false ,
99
+ is_lowering_assignee_expr : false ,
99
100
}
100
101
. collect ( params, body)
101
102
}
@@ -109,6 +110,7 @@ struct ExprCollector<'a> {
109
110
// a poor-mans union-find?
110
111
name_to_pat_grouping : FxHashMap < Name , Vec < PatId > > ,
111
112
is_lowering_inside_or_pat : bool ,
113
+ is_lowering_assignee_expr : bool ,
112
114
}
113
115
114
116
impl ExprCollector < ' _ > {
@@ -283,7 +285,10 @@ impl ExprCollector<'_> {
283
285
} else {
284
286
Box :: default ( )
285
287
} ;
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
+ )
287
292
}
288
293
ast:: Expr :: MethodCallExpr ( e) => {
289
294
let receiver = self . collect_expr_opt ( e. receiver ( ) ) ;
@@ -359,6 +364,7 @@ impl ExprCollector<'_> {
359
364
ast:: Expr :: RecordExpr ( e) => {
360
365
let path =
361
366
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 ;
362
368
let record_lit = if let Some ( nfl) = e. record_expr_field_list ( ) {
363
369
let fields = nfl
364
370
. fields ( )
@@ -378,9 +384,16 @@ impl ExprCollector<'_> {
378
384
} )
379
385
. collect ( ) ;
380
386
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 }
382
389
} 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
+ }
384
397
} ;
385
398
386
399
self . alloc_expr ( record_lit, syntax_ptr)
@@ -458,14 +471,21 @@ impl ExprCollector<'_> {
458
471
)
459
472
}
460
473
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
+ }
461
478
let lhs = self . collect_expr_opt ( e. lhs ( ) ) ;
479
+ self . is_lowering_assignee_expr = false ;
462
480
let rhs = self . collect_expr_opt ( e. rhs ( ) ) ;
463
- let op = e. op_kind ( ) ;
464
481
self . alloc_expr ( Expr :: BinaryOp { lhs, rhs, op } , syntax_ptr)
465
482
}
466
483
ast:: Expr :: TupleExpr ( e) => {
467
484
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
+ )
469
489
}
470
490
ast:: Expr :: BoxExpr ( e) => {
471
491
let expr = self . collect_expr_opt ( e. expr ( ) ) ;
@@ -477,8 +497,14 @@ impl ExprCollector<'_> {
477
497
478
498
match kind {
479
499
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
+ )
482
508
}
483
509
ArrayExprKind :: Repeat { initializer, repeat } => {
484
510
let initializer = self . collect_expr_opt ( initializer) ;
0 commit comments