Skip to content

Commit 21a3b39

Browse files
committed
Use record_operands_moved more in mir building
1 parent a17c837 commit 21a3b39

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

compiler/rustc_mir_build/src/build/expr/as_rvalue.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ use rustc_middle::ty::{self, Ty, UpvarArgs};
2020
use rustc_span::{Span, DUMMY_SP};
2121
use tracing::debug;
2222

23+
use std::slice;
24+
2325
impl<'a, 'tcx> Builder<'a, 'tcx> {
2426
/// Returns an rvalue suitable for use until the end of the current
2527
/// scope expression.
@@ -192,7 +194,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
192194
value,
193195
)
194196
);
195-
block.and(Rvalue::Use(Operand::Move(Place::from(result))))
197+
let result_operand = Operand::Move(Place::from(result));
198+
this.record_operands_moved(slice::from_ref(&result_operand));
199+
block.and(Rvalue::Use(result_operand))
196200
}
197201
ExprKind::Cast { source } => {
198202
let source_expr = &this.thir[source];
@@ -360,6 +364,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
360364
})
361365
.collect();
362366

367+
this.record_operands_moved(&fields.raw);
363368
block.and(Rvalue::Aggregate(Box::new(AggregateKind::Array(el_ty)), fields))
364369
}
365370
ExprKind::Tuple { ref fields } => {
@@ -381,6 +386,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
381386
})
382387
.collect();
383388

389+
this.record_operands_moved(&fields.raw);
384390
block.and(Rvalue::Aggregate(Box::new(AggregateKind::Tuple), fields))
385391
}
386392
ExprKind::Closure(box ClosureExpr {
@@ -483,6 +489,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
483489
Box::new(AggregateKind::CoroutineClosure(closure_id.to_def_id(), args))
484490
}
485491
};
492+
this.record_operands_moved(&operands.raw);
486493
block.and(Rvalue::Aggregate(result, operands))
487494
}
488495
ExprKind::Assign { .. } | ExprKind::AssignOp { .. } => {

compiler/rustc_mir_build/src/build/expr/into.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
383383
user_ty,
384384
active_field_index,
385385
));
386+
this.record_operands_moved(&fields.raw);
386387
this.cfg.push_assign(
387388
block,
388389
source_info,
@@ -561,6 +562,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
561562
)
562563
);
563564
let resume = this.cfg.start_new_block();
565+
this.record_operands_moved(slice::from_ref(&value));
564566
this.cfg.terminate(
565567
block,
566568
source_info,

0 commit comments

Comments
 (0)