@@ -39,7 +39,7 @@ use crate::{
39
39
mir:: {
40
40
intern_const_scalar, return_slot, AggregateKind , Arena , BasicBlock , BasicBlockId , BinOp ,
41
41
BorrowKind , CastKind , ClosureId , ConstScalar , Either , Expr , FieldId , Idx , InferenceResult ,
42
- Interner , Local , LocalId , MemoryMap , MirBody , MirSpan , Mutability , Operand , Place ,
42
+ Interner , Local , LocalId , MemoryMap , MirBody , MirSpan , Mutability , OperandKind , Place ,
43
43
PlaceElem , PointerCast , ProjectionElem , ProjectionStore , RawIdx , Rvalue , Statement ,
44
44
StatementKind , Substitution , SwitchTargets , Terminator , TerminatorKind , TupleFieldId , Ty ,
45
45
UnOp , VariantId ,
@@ -50,6 +50,8 @@ use crate::{
50
50
Adjust , Adjustment , AutoBorrow , CallableDefId , TyBuilder , TyExt ,
51
51
} ;
52
52
53
+ use super :: Operand ;
54
+
53
55
mod as_place;
54
56
mod pattern_matching;
55
57
@@ -326,7 +328,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
326
328
let Some ( ( p, current) ) = self . lower_expr_as_place ( current, expr_id, true ) ? else {
327
329
return Ok ( None ) ;
328
330
} ;
329
- Ok ( Some ( ( Operand :: Copy ( p) , current) ) )
331
+ Ok ( Some ( ( Operand { kind : OperandKind :: Copy ( p) , span : Some ( expr_id . into ( ) ) } , current) ) )
330
332
}
331
333
332
334
fn lower_expr_to_place_with_adjust (
@@ -349,7 +351,12 @@ impl<'ctx> MirLowerCtx<'ctx> {
349
351
else {
350
352
return Ok ( None ) ;
351
353
} ;
352
- self . push_assignment ( current, place, Operand :: Copy ( p) . into ( ) , expr_id. into ( ) ) ;
354
+ self . push_assignment (
355
+ current,
356
+ place,
357
+ Operand { kind : OperandKind :: Copy ( p) , span : None } . into ( ) ,
358
+ expr_id. into ( ) ,
359
+ ) ;
353
360
Ok ( Some ( current) )
354
361
}
355
362
Adjust :: Borrow ( AutoBorrow :: Ref ( _, m) | AutoBorrow :: RawPtr ( m) ) => {
@@ -373,7 +380,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
373
380
place,
374
381
Rvalue :: Cast (
375
382
CastKind :: PointerCoercion ( * cast) ,
376
- Operand :: Copy ( p) ,
383
+ Operand { kind : OperandKind :: Copy ( p) , span : None } ,
377
384
last. target . clone ( ) ,
378
385
) ,
379
386
expr_id. into ( ) ,
@@ -479,7 +486,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
479
486
self . push_assignment (
480
487
current,
481
488
place,
482
- Operand :: Copy ( temp) . into ( ) ,
489
+ Operand { kind : OperandKind :: Copy ( temp) , span : None } . into ( ) ,
483
490
expr_id. into ( ) ,
484
491
) ;
485
492
Ok ( Some ( current) )
@@ -520,20 +527,23 @@ impl<'ctx> MirLowerCtx<'ctx> {
520
527
self . push_assignment (
521
528
current,
522
529
place,
523
- Operand :: Constant (
524
- ConstData {
525
- ty,
526
- value : chalk_ir:: ConstValue :: BoundVar ( BoundVar :: new (
527
- DebruijnIndex :: INNERMOST ,
528
- gen. type_or_const_param_idx ( p. into ( ) ) . ok_or (
529
- MirLowerError :: TypeError (
530
- "fail to lower const generic param" ,
531
- ) ,
532
- ) ?,
533
- ) ) ,
534
- }
535
- . intern ( Interner ) ,
536
- )
530
+ Operand {
531
+ kind : OperandKind :: Constant (
532
+ ConstData {
533
+ ty,
534
+ value : chalk_ir:: ConstValue :: BoundVar ( BoundVar :: new (
535
+ DebruijnIndex :: INNERMOST ,
536
+ gen. type_or_const_param_idx ( p. into ( ) ) . ok_or (
537
+ MirLowerError :: TypeError (
538
+ "fail to lower const generic param" ,
539
+ ) ,
540
+ ) ?,
541
+ ) ) ,
542
+ }
543
+ . intern ( Interner ) ,
544
+ ) ,
545
+ span : None ,
546
+ }
537
547
. into ( ) ,
538
548
expr_id. into ( ) ,
539
549
) ;
@@ -879,7 +889,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
879
889
} ) ) ,
880
890
& mut self . result . projection_store ,
881
891
) ;
882
- Operand :: Copy ( p)
892
+ Operand { kind : OperandKind :: Copy ( p) , span : None }
883
893
}
884
894
} )
885
895
. collect ( ) ,
@@ -981,7 +991,12 @@ impl<'ctx> MirLowerCtx<'ctx> {
981
991
else {
982
992
return Ok ( None ) ;
983
993
} ;
984
- self . push_assignment ( current, place, Operand :: Copy ( p) . into ( ) , expr_id. into ( ) ) ;
994
+ self . push_assignment (
995
+ current,
996
+ place,
997
+ Operand { kind : OperandKind :: Copy ( p) , span : None } . into ( ) ,
998
+ expr_id. into ( ) ,
999
+ ) ;
985
1000
Ok ( Some ( current) )
986
1001
}
987
1002
Expr :: UnaryOp {
@@ -1058,8 +1073,11 @@ impl<'ctx> MirLowerCtx<'ctx> {
1058
1073
else {
1059
1074
return Ok ( None ) ;
1060
1075
} ;
1061
- let r_value =
1062
- Rvalue :: CheckedBinaryOp ( op. into ( ) , Operand :: Copy ( lhs_place) , rhs_op) ;
1076
+ let r_value = Rvalue :: CheckedBinaryOp (
1077
+ op. into ( ) ,
1078
+ Operand { kind : OperandKind :: Copy ( lhs_place) , span : None } ,
1079
+ rhs_op,
1080
+ ) ;
1063
1081
self . push_assignment ( current, lhs_place, r_value, expr_id. into ( ) ) ;
1064
1082
return Ok ( Some ( current) ) ;
1065
1083
}
@@ -1235,9 +1253,11 @@ impl<'ctx> MirLowerCtx<'ctx> {
1235
1253
Rvalue :: Ref ( * bk, p) ,
1236
1254
capture_spans[ 0 ] ,
1237
1255
) ;
1238
- operands. push ( Operand :: Move ( tmp) ) ;
1256
+ operands. push ( Operand { kind : OperandKind :: Move ( tmp) , span : None } ) ;
1257
+ }
1258
+ CaptureKind :: ByValue => {
1259
+ operands. push ( Operand { kind : OperandKind :: Move ( p) , span : None } )
1239
1260
}
1240
- CaptureKind :: ByValue => operands. push ( Operand :: Move ( p) ) ,
1241
1261
}
1242
1262
}
1243
1263
self . push_assignment (
@@ -1472,7 +1492,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
1472
1492
. const_eval ( const_id, subst, None )
1473
1493
. map_err ( |e| MirLowerError :: ConstEvalError ( name. into ( ) , Box :: new ( e) ) ) ?
1474
1494
} ;
1475
- Ok ( Operand :: Constant ( c) )
1495
+ Ok ( Operand { kind : OperandKind :: Constant ( c) , span : None } )
1476
1496
}
1477
1497
1478
1498
fn write_bytes_to_place (
0 commit comments