Skip to content

Commit 2539e00

Browse files
authored
Rollup merge of rust-lang#72425 - RalfJung:discr-sign-ext, r=nikomatsakis
fix discriminant_value sign extension Fixes a regression introduced in rust-lang#70705 r? @nikomatsakis Cc @lcnr @oli-obk
2 parents 284acc8 + 94aa028 commit 2539e00

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/librustc_mir/interpret/intrinsics.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
219219
let place = self.deref_operand(args[0])?;
220220
let discr_val = self.read_discriminant(place.into())?.0;
221221
let scalar = match dest.layout.ty.kind {
222-
ty::Int(_) => Scalar::from_int(discr_val as i128, dest.layout.size),
222+
ty::Int(_) => Scalar::from_int(
223+
self.sign_extend(discr_val, dest.layout) as i128,
224+
dest.layout.size,
225+
),
223226
ty::Uint(_) => Scalar::from_uint(discr_val, dest.layout.size),
224227
_ => bug!("invalid `discriminant_value` return layout: {:?}", dest.layout),
225228
};

0 commit comments

Comments
 (0)