@@ -50,6 +50,8 @@ use crate::{
50
50
utils:: ClosureSubst ,
51
51
} ;
52
52
53
+ use super :: OperandKind ;
54
+
53
55
mod as_place;
54
56
mod pattern_matching;
55
57
@@ -329,7 +331,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
329
331
let Some ( ( p, current) ) = self . lower_expr_as_place ( current, expr_id, true ) ? else {
330
332
return Ok ( None ) ;
331
333
} ;
332
- Ok ( Some ( ( Operand :: Copy ( p) , current) ) )
334
+ Ok ( Some ( ( Operand { kind : OperandKind :: Copy ( p) , span : Some ( expr_id . into ( ) ) } , current) ) )
333
335
}
334
336
335
337
fn lower_expr_to_place_with_adjust (
@@ -352,7 +354,12 @@ impl<'ctx> MirLowerCtx<'ctx> {
352
354
else {
353
355
return Ok ( None ) ;
354
356
} ;
355
- self . push_assignment ( current, place, Operand :: Copy ( p) . into ( ) , expr_id. into ( ) ) ;
357
+ self . push_assignment (
358
+ current,
359
+ place,
360
+ Operand { kind : OperandKind :: Copy ( p) , span : None } . into ( ) ,
361
+ expr_id. into ( ) ,
362
+ ) ;
356
363
Ok ( Some ( current) )
357
364
}
358
365
Adjust :: Borrow ( AutoBorrow :: Ref ( _, m) | AutoBorrow :: RawPtr ( m) ) => {
@@ -376,7 +383,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
376
383
place,
377
384
Rvalue :: Cast (
378
385
CastKind :: PointerCoercion ( * cast) ,
379
- Operand :: Copy ( p) ,
386
+ Operand { kind : OperandKind :: Copy ( p) , span : None } ,
380
387
last. target . clone ( ) ,
381
388
) ,
382
389
expr_id. into ( ) ,
@@ -482,7 +489,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
482
489
self . push_assignment (
483
490
current,
484
491
place,
485
- Operand :: Copy ( temp) . into ( ) ,
492
+ Operand { kind : OperandKind :: Copy ( temp) , span : None } . into ( ) ,
486
493
expr_id. into ( ) ,
487
494
) ;
488
495
Ok ( Some ( current) )
@@ -523,21 +530,24 @@ impl<'ctx> MirLowerCtx<'ctx> {
523
530
self . push_assignment (
524
531
current,
525
532
place,
526
- Operand :: Constant (
527
- ConstData {
528
- ty,
529
- value : chalk_ir:: ConstValue :: BoundVar ( BoundVar :: new (
530
- DebruijnIndex :: INNERMOST ,
531
- generics. type_or_const_param_idx ( p. into ( ) ) . ok_or (
532
- MirLowerError :: TypeError (
533
- "fail to lower const generic param" ,
534
- ) ,
535
- ) ?,
536
- ) ) ,
537
- }
538
- . intern ( Interner ) ,
539
- )
540
- . into ( ) ,
533
+ Rvalue :: from ( Operand {
534
+ kind : OperandKind :: Constant (
535
+ ConstData {
536
+ ty,
537
+ value : chalk_ir:: ConstValue :: BoundVar ( BoundVar :: new (
538
+ DebruijnIndex :: INNERMOST ,
539
+ generics. type_or_const_param_idx ( p. into ( ) ) . ok_or (
540
+ MirLowerError :: TypeError (
541
+ "fail to lower const generic param" ,
542
+ ) ,
543
+ ) ?,
544
+ ) ) ,
545
+ }
546
+ . intern ( Interner ) ,
547
+ )
548
+ . into ( ) ,
549
+ span : None ,
550
+ } ) ,
541
551
expr_id. into ( ) ,
542
552
) ;
543
553
Ok ( Some ( current) )
@@ -882,7 +892,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
882
892
} ) ) ,
883
893
& mut self . result . projection_store ,
884
894
) ;
885
- Operand :: Copy ( p)
895
+ Operand { kind : OperandKind :: Copy ( p) , span : None }
886
896
}
887
897
} )
888
898
. collect ( ) ,
@@ -984,7 +994,12 @@ impl<'ctx> MirLowerCtx<'ctx> {
984
994
else {
985
995
return Ok ( None ) ;
986
996
} ;
987
- self . push_assignment ( current, place, Operand :: Copy ( p) . into ( ) , expr_id. into ( ) ) ;
997
+ self . push_assignment (
998
+ current,
999
+ place,
1000
+ Operand { kind : OperandKind :: Copy ( p) , span : None } . into ( ) ,
1001
+ expr_id. into ( ) ,
1002
+ ) ;
988
1003
Ok ( Some ( current) )
989
1004
}
990
1005
Expr :: UnaryOp {
@@ -1061,8 +1076,11 @@ impl<'ctx> MirLowerCtx<'ctx> {
1061
1076
else {
1062
1077
return Ok ( None ) ;
1063
1078
} ;
1064
- let r_value =
1065
- Rvalue :: CheckedBinaryOp ( op. into ( ) , Operand :: Copy ( lhs_place) , rhs_op) ;
1079
+ let r_value = Rvalue :: CheckedBinaryOp (
1080
+ op. into ( ) ,
1081
+ Operand { kind : OperandKind :: Copy ( lhs_place) , span : None } ,
1082
+ rhs_op,
1083
+ ) ;
1066
1084
self . push_assignment ( current, lhs_place, r_value, expr_id. into ( ) ) ;
1067
1085
return Ok ( Some ( current) ) ;
1068
1086
}
@@ -1237,9 +1255,11 @@ impl<'ctx> MirLowerCtx<'ctx> {
1237
1255
Rvalue :: Ref ( * bk, p) ,
1238
1256
capture_spans[ 0 ] ,
1239
1257
) ;
1240
- operands. push ( Operand :: Move ( tmp) ) ;
1258
+ operands. push ( Operand { kind : OperandKind :: Move ( tmp) , span : None } ) ;
1259
+ }
1260
+ CaptureKind :: ByValue => {
1261
+ operands. push ( Operand { kind : OperandKind :: Move ( p) , span : None } )
1241
1262
}
1242
- CaptureKind :: ByValue => operands. push ( Operand :: Move ( p) ) ,
1243
1263
}
1244
1264
}
1245
1265
self . push_assignment (
@@ -1481,7 +1501,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
1481
1501
. const_eval ( const_id, subst, None )
1482
1502
. map_err ( |e| MirLowerError :: ConstEvalError ( name. into ( ) , Box :: new ( e) ) ) ?
1483
1503
} ;
1484
- Ok ( Operand :: Constant ( c) )
1504
+ Ok ( Operand { kind : OperandKind :: Constant ( c) , span : None } )
1485
1505
}
1486
1506
1487
1507
fn write_bytes_to_place (
0 commit comments