Skip to content

Commit

Permalink
Ensure enum cast moves
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Oct 13, 2022
1 parent 4891d57 commit de0396c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// create all the steps directly in MIR with operations all backends need to support anyway.
let (source, ty) = if let ty::Adt(adt_def, ..) = source.ty.kind() && adt_def.is_enum() {
let discr_ty = adt_def.repr().discr_type().to_ty(this.tcx);
let place = unpack!(block = this.as_place(block, source));
let temp = unpack!(block = this.as_temp(block, scope, source, Mutability::Not));
let discr = this.temp(discr_ty, source.span);
this.cfg.push_assign(
block,
source_info,
discr,
Rvalue::Discriminant(place),
Rvalue::Discriminant(temp.into()),
);

(Operand::Move(discr), discr_ty)
Expand Down

0 comments on commit de0396c

Please sign in to comment.