Skip to content

Commit f8c7210

Browse files
committed
Use record_operands_moved more in mir building
1 parent ae1088a commit f8c7210

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
@@ -382,6 +382,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
382382
user_ty,
383383
active_field_index,
384384
));
385+
this.record_operands_moved(&fields.raw);
385386
this.cfg.push_assign(
386387
block,
387388
source_info,
@@ -560,6 +561,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
560561
)
561562
);
562563
let resume = this.cfg.start_new_block();
564+
this.record_operands_moved(slice::from_ref(&value));
563565
this.cfg.terminate(
564566
block,
565567
source_info,

0 commit comments

Comments
 (0)