@@ -43,6 +43,15 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
43
43
rvalue) ;
44
44
45
45
match * rvalue {
46
+ mir:: Rvalue :: Use ( ref operand) => {
47
+ // FIXME: consider not copying constants through stack. (fixable by translating
48
+ // constants into OperandValue::Ref, why don’t we do that yet if we don’t?)
49
+ let tr_operand = self . trans_operand ( bcx, operand) ;
50
+ self . store_operand ( bcx, dest. llval , tr_operand) ;
51
+ self . set_operand_dropped ( bcx, operand) ;
52
+ bcx
53
+ }
54
+
46
55
mir:: Rvalue :: Cast ( mir:: CastKind :: Unsize , ref operand, cast_ty) => {
47
56
if common:: type_is_fat_ptr ( bcx. tcx ( ) , cast_ty) {
48
57
// into-coerce of a thin pointer to a fat pointer - just
@@ -162,13 +171,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
162
171
assert ! ( rvalue_creates_operand( rvalue) , "cannot trans {:?} to operand" , rvalue) ;
163
172
164
173
match * rvalue {
165
- mir:: Rvalue :: Use ( ref operand) => {
166
- // FIXME: consider not copying constants through stack. (fixable by translating
167
- // constants into OperandValue::Ref, why don’t we do that yet if we don’t?)
168
- let operand = self . trans_operand ( bcx, operand) ;
169
- ( bcx, operand)
170
- }
171
-
172
174
mir:: Rvalue :: Cast ( ref kind, ref operand, cast_ty) => {
173
175
let operand = self . trans_operand ( bcx, operand) ;
174
176
debug ! ( "cast operand is {}" , operand. repr( bcx) ) ;
@@ -398,6 +400,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
398
400
} )
399
401
}
400
402
403
+ mir:: Rvalue :: Use ( ..) |
401
404
mir:: Rvalue :: Repeat ( ..) |
402
405
mir:: Rvalue :: Aggregate ( ..) |
403
406
mir:: Rvalue :: Slice { .. } |
@@ -508,14 +511,14 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
508
511
509
512
pub fn rvalue_creates_operand < ' tcx > ( rvalue : & mir:: Rvalue < ' tcx > ) -> bool {
510
513
match * rvalue {
511
- mir:: Rvalue :: Use ( ..) | // (*)
512
514
mir:: Rvalue :: Ref ( ..) |
513
515
mir:: Rvalue :: Len ( ..) |
514
516
mir:: Rvalue :: Cast ( ..) | // (*)
515
517
mir:: Rvalue :: BinaryOp ( ..) |
516
518
mir:: Rvalue :: UnaryOp ( ..) |
517
519
mir:: Rvalue :: Box ( ..) =>
518
520
true ,
521
+ mir:: Rvalue :: Use ( ..) | // (**)
519
522
mir:: Rvalue :: Repeat ( ..) |
520
523
mir:: Rvalue :: Aggregate ( ..) |
521
524
mir:: Rvalue :: Slice { .. } |
@@ -524,4 +527,6 @@ pub fn rvalue_creates_operand<'tcx>(rvalue: &mir::Rvalue<'tcx>) -> bool {
524
527
}
525
528
526
529
// (*) this is only true if the type is suitable
530
+ // (**) we need to zero-out the old value before moving, so we are restricted to either
531
+ // ensuring all users of `Use` set it themselves or not allowing to “create” operand for it.
527
532
}
0 commit comments