@@ -48,6 +48,8 @@ use crate::{
4848 utils:: ClosureSubst ,
4949} ;
5050
51+ use super :: OperandKind ;
52+
5153mod as_place;
5254mod pattern_matching;
5355
@@ -324,7 +326,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
324326 let Some ( ( p, current) ) = self . lower_expr_as_place ( current, expr_id, true ) ? else {
325327 return Ok ( None ) ;
326328 } ;
327- Ok ( Some ( ( Operand :: Copy ( p) , current) ) )
329+ Ok ( Some ( ( Operand { kind : OperandKind :: Copy ( p) , span : Some ( expr_id . into ( ) ) } , current) ) )
328330 }
329331
330332 fn lower_expr_to_place_with_adjust (
@@ -347,7 +349,12 @@ impl<'ctx> MirLowerCtx<'ctx> {
347349 else {
348350 return Ok ( None ) ;
349351 } ;
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+ ) ;
351358 Ok ( Some ( current) )
352359 }
353360 Adjust :: Borrow ( AutoBorrow :: Ref ( _, m) | AutoBorrow :: RawPtr ( m) ) => {
@@ -371,7 +378,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
371378 place,
372379 Rvalue :: Cast (
373380 CastKind :: PointerCoercion ( * cast) ,
374- Operand :: Copy ( p) ,
381+ Operand { kind : OperandKind :: Copy ( p) , span : None } ,
375382 last. target . clone ( ) ,
376383 ) ,
377384 expr_id. into ( ) ,
@@ -476,7 +483,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
476483 self . push_assignment (
477484 current,
478485 place,
479- Operand :: Copy ( temp) . into ( ) ,
486+ Operand { kind : OperandKind :: Copy ( temp) , span : None } . into ( ) ,
480487 expr_id. into ( ) ,
481488 ) ;
482489 Ok ( Some ( current) )
@@ -517,21 +524,23 @@ impl<'ctx> MirLowerCtx<'ctx> {
517524 self . push_assignment (
518525 current,
519526 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+ } ) ,
535544 expr_id. into ( ) ,
536545 ) ;
537546 Ok ( Some ( current) )
@@ -876,7 +885,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
876885 } ) ) ,
877886 & mut self . result . projection_store ,
878887 ) ;
879- Operand :: Copy ( p)
888+ Operand { kind : OperandKind :: Copy ( p) , span : None }
880889 }
881890 } )
882891 . collect ( ) ,
@@ -979,7 +988,12 @@ impl<'ctx> MirLowerCtx<'ctx> {
979988 else {
980989 return Ok ( None ) ;
981990 } ;
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+ ) ;
983997 Ok ( Some ( current) )
984998 }
985999 Expr :: UnaryOp {
@@ -1056,8 +1070,11 @@ impl<'ctx> MirLowerCtx<'ctx> {
10561070 else {
10571071 return Ok ( None ) ;
10581072 } ;
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+ ) ;
10611078 self . push_assignment ( current, lhs_place, r_value, expr_id. into ( ) ) ;
10621079 return Ok ( Some ( current) ) ;
10631080 }
@@ -1232,9 +1249,11 @@ impl<'ctx> MirLowerCtx<'ctx> {
12321249 Rvalue :: Ref ( * bk, p) ,
12331250 capture_spans[ 0 ] ,
12341251 ) ;
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 } )
12361256 }
1237- CaptureKind :: ByValue => operands. push ( Operand :: Move ( p) ) ,
12381257 }
12391258 }
12401259 self . push_assignment (
@@ -1476,7 +1495,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
14761495 . const_eval ( const_id, subst, None )
14771496 . map_err ( |e| MirLowerError :: ConstEvalError ( name. into ( ) , Box :: new ( e) ) ) ?
14781497 } ;
1479- Ok ( Operand :: Constant ( c) )
1498+ Ok ( Operand { kind : OperandKind :: Constant ( c) , span : None } )
14801499 }
14811500
14821501 fn write_bytes_to_place (
0 commit comments