mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
make InterpResult a dedicated type to avoid accidentally discarding the error
This commit is contained in:
parent
ad3464493d
commit
4891dd4627
@ -870,10 +870,10 @@ pub fn mir_to_const<'tcx>(tcx: TyCtxt<'tcx>, result: mir::Const<'tcx>) -> Option
|
||||
let range = alloc_range(offset + size * idx, size);
|
||||
let val = alloc.read_scalar(&tcx, range, /* read_provenance */ false).ok()?;
|
||||
res.push(match flt {
|
||||
FloatTy::F16 => Constant::F16(f16::from_bits(val.to_u16().ok()?)),
|
||||
FloatTy::F32 => Constant::F32(f32::from_bits(val.to_u32().ok()?)),
|
||||
FloatTy::F64 => Constant::F64(f64::from_bits(val.to_u64().ok()?)),
|
||||
FloatTy::F128 => Constant::F128(f128::from_bits(val.to_u128().ok()?)),
|
||||
FloatTy::F16 => Constant::F16(f16::from_bits(val.to_u16().discard_err()?)),
|
||||
FloatTy::F32 => Constant::F32(f32::from_bits(val.to_u32().discard_err()?)),
|
||||
FloatTy::F64 => Constant::F64(f64::from_bits(val.to_u64().discard_err()?)),
|
||||
FloatTy::F128 => Constant::F128(f128::from_bits(val.to_u128().discard_err()?)),
|
||||
});
|
||||
}
|
||||
Some(Constant::Vec(res))
|
||||
@ -903,7 +903,7 @@ fn mir_is_empty<'tcx>(tcx: TyCtxt<'tcx>, result: mir::Const<'tcx>) -> Option<boo
|
||||
.read_scalar(&tcx, alloc_range(offset + ptr_size, ptr_size), false)
|
||||
.ok()?
|
||||
.to_target_usize(&tcx)
|
||||
.ok()?;
|
||||
.discard_err()?;
|
||||
Some(len == 0)
|
||||
} else {
|
||||
None
|
||||
|
Loading…
Reference in New Issue
Block a user