Skip to content

Commit de0396c

Browse files
committed
Ensure enum cast moves
1 parent 4891d57 commit de0396c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
197197
// create all the steps directly in MIR with operations all backends need to support anyway.
198198
let (source, ty) = if let ty::Adt(adt_def, ..) = source.ty.kind() && adt_def.is_enum() {
199199
let discr_ty = adt_def.repr().discr_type().to_ty(this.tcx);
200-
let place = unpack!(block = this.as_place(block, source));
200+
let temp = unpack!(block = this.as_temp(block, scope, source, Mutability::Not));
201201
let discr = this.temp(discr_ty, source.span);
202202
this.cfg.push_assign(
203203
block,
204204
source_info,
205205
discr,
206-
Rvalue::Discriminant(place),
206+
Rvalue::Discriminant(temp.into()),
207207
);
208208

209209
(Operand::Move(discr), discr_ty)

0 commit comments

Comments
 (0)