Skip to content

Commit f2b8005

Browse files
committed
Use record_operands_moved more in mir building
1 parent 2b6fd1b commit f2b8005

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

+8-1
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.
@@ -191,7 +193,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
191193
value,
192194
)
193195
);
194-
block.and(Rvalue::Use(Operand::Move(Place::from(result))))
196+
let result_operand = Operand::Move(Place::from(result));
197+
this.record_operands_moved(slice::from_ref(&result_operand));
198+
block.and(Rvalue::Use(result_operand))
195199
}
196200
ExprKind::Cast { source } => {
197201
let source_expr = &this.thir[source];
@@ -359,6 +363,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
359363
})
360364
.collect();
361365

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

388+
this.record_operands_moved(&fields.raw);
383389
block.and(Rvalue::Aggregate(Box::new(AggregateKind::Tuple), fields))
384390
}
385391
ExprKind::Closure(box ClosureExpr {
@@ -482,6 +488,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
482488
Box::new(AggregateKind::CoroutineClosure(closure_id.to_def_id(), args))
483489
}
484490
};
491+
this.record_operands_moved(&operands.raw);
485492
block.and(Rvalue::Aggregate(result, operands))
486493
}
487494
ExprKind::Assign { .. } | ExprKind::AssignOp { .. } => {

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

+2
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
379379
user_ty,
380380
active_field_index,
381381
));
382+
this.record_operands_moved(&fields.raw);
382383
this.cfg.push_assign(
383384
block,
384385
source_info,
@@ -557,6 +558,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
557558
)
558559
);
559560
let resume = this.cfg.start_new_block();
561+
this.record_operands_moved(slice::from_ref(&value));
560562
this.cfg.terminate(
561563
block,
562564
source_info,

0 commit comments

Comments
 (0)