Skip to content

Commit

Permalink
Rollup merge of #72425 - RalfJung:discr-sign-ext, r=nikomatsakis
Browse files Browse the repository at this point in the history
fix discriminant_value sign extension

Fixes a regression introduced in #70705
r? @nikomatsakis Cc @lcnr @oli-obk
  • Loading branch information
RalfJung authored May 21, 2020
2 parents fc729d0 + 94aa028 commit 74b5c50
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/librustc_mir/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let place = self.deref_operand(args[0])?;
let discr_val = self.read_discriminant(place.into())?.0;
let scalar = match dest.layout.ty.kind {
ty::Int(_) => Scalar::from_int(discr_val as i128, dest.layout.size),
ty::Int(_) => Scalar::from_int(
self.sign_extend(discr_val, dest.layout) as i128,
dest.layout.size,
),
ty::Uint(_) => Scalar::from_uint(discr_val, dest.layout.size),
_ => bug!("invalid `discriminant_value` return layout: {:?}", dest.layout),
};
Expand Down

0 comments on commit 74b5c50

Please sign in to comment.