Abi::is_signed: assert that we are a Scalar

This commit is contained in:
Ralf Jung 2020-03-20 17:05:00 +01:00
parent f4c675c476
commit 5930da4465
2 changed files with 2 additions and 2 deletions

View File

@ -603,7 +603,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
.not_undef()
.and_then(|raw_discr| self.force_bits(raw_discr, discr_val.layout.size))
.map_err(|_| err_ub!(InvalidDiscriminant(raw_discr.erase_tag())))?;
let real_discr = if discr_val.layout.ty.is_signed() {
let real_discr = if discr_val.layout.abi.is_signed() {
// going from layout tag type to typeck discriminant type
// requires first sign extending with the discriminant layout
let sexted = sign_extend(bits_discr, discr_val.layout.size) as i128;

View File

@ -748,7 +748,7 @@ impl Abi {
Primitive::Int(_, signed) => signed,
_ => false,
},
_ => false,
_ => panic!("`is_signed` on non-scalar ABI {:?}", self),
}
}