Rollup merge of #70126 - wesleywiser:fix_miri_ice_neg_zst_enum_discr, r=RalfJung,eddyb

Fix ICE caused by truncating a negative ZST enum discriminant

Fixes #70114

r? @oli-obk or @RalfJung
This commit is contained in:
Dylan DPC 2020-03-21 22:56:20 +01:00 committed by GitHub
commit ecf3ef52a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 4 deletions

View file

@ -293,7 +293,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
if let Some(discr) =
operand.layout.ty.discriminant_for_variant(bx.tcx(), index)
{
let discr_val = bx.cx().const_uint_big(ll_t_out, discr.val);
let discr_layout = bx.cx().layout_of(discr.ty);
let discr_t = bx.cx().immediate_backend_type(discr_layout);
let discr_val = bx.cx().const_uint_big(discr_t, discr.val);
let discr_val =
bx.intcast(discr_val, ll_t_out, discr.ty.is_signed());
return (
bx,
OperandRef {