No silent truncating of SwitchInt values

This commit is contained in:
bjorn3 2020-07-13 19:45:46 +02:00
parent 8dfb1daea7
commit 4ec2831ebc

View File

@ -283,7 +283,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) {
let mut switch = ::cranelift_frontend::Switch::new();
for (i, value) in values.iter().enumerate() {
let block = fx.get_block(targets[i]);
switch.set_entry(*value as u64, block);
switch.set_entry((*value).try_into().unwrap(), block);
}
let otherwise_block = fx.get_block(targets[targets.len() - 1]);
switch.emit(&mut fx.bcx, discr, otherwise_block);