Skip to content

Commit 19857d9

Browse files
committed
Allow Operand::Copy with non-Copy types during MIR optimizations
1 parent 4e12b1f commit 19857d9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/rustc_mir/src/transform/validate.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,11 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
203203

204204
fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) {
205205
// This check is somewhat expensive, so only run it when -Zvalidate-mir is passed.
206-
if self.tcx.sess.opts.debugging_opts.validate_mir {
207-
// `Operand::Copy` is only supposed to be used with `Copy` types.
206+
if self.tcx.sess.opts.debugging_opts.validate_mir
207+
&& self.mir_phase < MirPhase::GeneratorLowering
208+
{
209+
// `Operand::Copy` is only supposed to be used with `Copy` types before MIR
210+
// optimizations.
208211
if let Operand::Copy(place) = operand {
209212
let ty = place.ty(&self.body.local_decls, self.tcx).ty;
210213
let span = self.body.source_info(location).span;

0 commit comments

Comments
 (0)