@@ -48,6 +48,8 @@ use crate::{
48
48
utils:: ClosureSubst ,
49
49
} ;
50
50
51
+ use super :: OperandKind ;
52
+
51
53
mod as_place;
52
54
mod pattern_matching;
53
55
@@ -324,7 +326,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
324
326
let Some ( ( p, current) ) = self . lower_expr_as_place ( current, expr_id, true ) ? else {
325
327
return Ok ( None ) ;
326
328
} ;
327
- Ok ( Some ( ( Operand :: Copy ( p) , current) ) )
329
+ Ok ( Some ( ( Operand { kind : OperandKind :: Copy ( p) , span : Some ( expr_id . into ( ) ) } , current) ) )
328
330
}
329
331
330
332
fn lower_expr_to_place_with_adjust (
@@ -347,7 +349,12 @@ impl<'ctx> MirLowerCtx<'ctx> {
347
349
else {
348
350
return Ok ( None ) ;
349
351
} ;
350
- self . push_assignment ( current, place, Operand :: Copy ( p) . into ( ) , expr_id. into ( ) ) ;
352
+ self . push_assignment (
353
+ current,
354
+ place,
355
+ Operand { kind : OperandKind :: Copy ( p) , span : None } . into ( ) ,
356
+ expr_id. into ( ) ,
357
+ ) ;
351
358
Ok ( Some ( current) )
352
359
}
353
360
Adjust :: Borrow ( AutoBorrow :: Ref ( _, m) | AutoBorrow :: RawPtr ( m) ) => {
@@ -371,7 +378,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
371
378
place,
372
379
Rvalue :: Cast (
373
380
CastKind :: PointerCoercion ( * cast) ,
374
- Operand :: Copy ( p) ,
381
+ Operand { kind : OperandKind :: Copy ( p) , span : None } ,
375
382
last. target . clone ( ) ,
376
383
) ,
377
384
expr_id. into ( ) ,
@@ -476,7 +483,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
476
483
self . push_assignment (
477
484
current,
478
485
place,
479
- Operand :: Copy ( temp) . into ( ) ,
486
+ Operand { kind : OperandKind :: Copy ( temp) , span : None } . into ( ) ,
480
487
expr_id. into ( ) ,
481
488
) ;
482
489
Ok ( Some ( current) )
@@ -517,21 +524,23 @@ impl<'ctx> MirLowerCtx<'ctx> {
517
524
self . push_assignment (
518
525
current,
519
526
place,
520
- Operand :: Constant (
521
- ConstData {
522
- ty,
523
- value : chalk_ir:: ConstValue :: BoundVar ( BoundVar :: new (
524
- DebruijnIndex :: INNERMOST ,
525
- generics. type_or_const_param_idx ( p. into ( ) ) . ok_or (
526
- MirLowerError :: TypeError (
527
- "fail to lower const generic param" ,
528
- ) ,
529
- ) ?,
530
- ) ) ,
531
- }
532
- . intern ( Interner ) ,
533
- )
534
- . into ( ) ,
527
+ Rvalue :: from ( Operand {
528
+ kind : OperandKind :: Constant (
529
+ ConstData {
530
+ ty,
531
+ value : chalk_ir:: ConstValue :: BoundVar ( BoundVar :: new (
532
+ DebruijnIndex :: INNERMOST ,
533
+ generics. type_or_const_param_idx ( p. into ( ) ) . ok_or (
534
+ MirLowerError :: TypeError (
535
+ "fail to lower const generic param" ,
536
+ ) ,
537
+ ) ?,
538
+ ) ) ,
539
+ }
540
+ . intern ( Interner ) ,
541
+ ) ,
542
+ span : None ,
543
+ } ) ,
535
544
expr_id. into ( ) ,
536
545
) ;
537
546
Ok ( Some ( current) )
@@ -876,7 +885,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
876
885
} ) ) ,
877
886
& mut self . result . projection_store ,
878
887
) ;
879
- Operand :: Copy ( p)
888
+ Operand { kind : OperandKind :: Copy ( p) , span : None }
880
889
}
881
890
} )
882
891
. collect ( ) ,
@@ -979,7 +988,12 @@ impl<'ctx> MirLowerCtx<'ctx> {
979
988
else {
980
989
return Ok ( None ) ;
981
990
} ;
982
- self . push_assignment ( current, place, Operand :: Copy ( p) . into ( ) , expr_id. into ( ) ) ;
991
+ self . push_assignment (
992
+ current,
993
+ place,
994
+ Operand { kind : OperandKind :: Copy ( p) , span : None } . into ( ) ,
995
+ expr_id. into ( ) ,
996
+ ) ;
983
997
Ok ( Some ( current) )
984
998
}
985
999
Expr :: UnaryOp {
@@ -1056,8 +1070,11 @@ impl<'ctx> MirLowerCtx<'ctx> {
1056
1070
else {
1057
1071
return Ok ( None ) ;
1058
1072
} ;
1059
- let r_value =
1060
- Rvalue :: CheckedBinaryOp ( op. into ( ) , Operand :: Copy ( lhs_place) , rhs_op) ;
1073
+ let r_value = Rvalue :: CheckedBinaryOp (
1074
+ op. into ( ) ,
1075
+ Operand { kind : OperandKind :: Copy ( lhs_place) , span : None } ,
1076
+ rhs_op,
1077
+ ) ;
1061
1078
self . push_assignment ( current, lhs_place, r_value, expr_id. into ( ) ) ;
1062
1079
return Ok ( Some ( current) ) ;
1063
1080
}
@@ -1232,9 +1249,11 @@ impl<'ctx> MirLowerCtx<'ctx> {
1232
1249
Rvalue :: Ref ( * bk, p) ,
1233
1250
capture_spans[ 0 ] ,
1234
1251
) ;
1235
- operands. push ( Operand :: Move ( tmp) ) ;
1252
+ operands. push ( Operand { kind : OperandKind :: Move ( tmp) , span : None } ) ;
1253
+ }
1254
+ CaptureKind :: ByValue => {
1255
+ operands. push ( Operand { kind : OperandKind :: Move ( p) , span : None } )
1236
1256
}
1237
- CaptureKind :: ByValue => operands. push ( Operand :: Move ( p) ) ,
1238
1257
}
1239
1258
}
1240
1259
self . push_assignment (
@@ -1476,7 +1495,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
1476
1495
. const_eval ( const_id, subst, None )
1477
1496
. map_err ( |e| MirLowerError :: ConstEvalError ( name. into ( ) , Box :: new ( e) ) ) ?
1478
1497
} ;
1479
- Ok ( Operand :: Constant ( c) )
1498
+ Ok ( Operand { kind : OperandKind :: Constant ( c) , span : None } )
1480
1499
}
1481
1500
1482
1501
fn write_bytes_to_place (
0 commit comments