rustup; get rid of some try_from that are no longer needed

This commit is contained in:
Ralf Jung 2020-03-26 00:11:50 +01:00
parent c6e8838b89
commit 81d505670b
4 changed files with 6 additions and 6 deletions

View file

@ -1 +1 @@
02046a5d402c789c006d0da7662f800fe3c45faf
a5fb9ae5b2ed3cb011ada9dc1e8633aa0927f279

View file

@ -114,7 +114,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
ecx.layout_of(tcx.mk_array(tcx.mk_imm_ptr(tcx.types.u8), u64::try_from(argvs.len()).unwrap()))?;
let argvs_place = ecx.allocate(argvs_layout, MiriMemoryKind::Machine.into());
for (idx, arg) in argvs.into_iter().enumerate() {
let place = ecx.mplace_field(argvs_place, u64::try_from(idx).unwrap())?;
let place = ecx.mplace_field(argvs_place, idx)?;
ecx.write_scalar(arg, place.into())?;
}
ecx.memory.mark_immutable(argvs_place.ptr.assert_ptr().alloc_id)?;
@ -154,7 +154,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
// Store the UTF-16 string. We just allocated so we know the bounds are fine.
let char_size = Size::from_bytes(2);
for (idx, &c) in cmd_utf16.iter().enumerate() {
let place = ecx.mplace_field(cmd_place, u64::try_from(idx).unwrap())?;
let place = ecx.mplace_field(cmd_place, idx)?;
ecx.write_scalar(Scalar::from_uint(c, char_size), place.into())?;
}
}

View file

@ -598,7 +598,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
// Store the UTF-16 string.
let char_size = Size::from_bytes(2);
for (idx, c) in u16_vec.into_iter().chain(iter::once(0x0000)).enumerate() {
let place = this.mplace_field(mplace, u64::try_from(idx).unwrap())?;
let place = this.mplace_field(mplace, idx)?;
this.write_scalar(Scalar::from_uint(c, char_size), place.into())?;
}
Ok((true, string_length))

View file

@ -61,7 +61,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
Ok(match this.machine.env_vars.map.get(name) {
// The offset is used to strip the "{name}=" part of the string.
Some(var_ptr) => {
Scalar::from(var_ptr.offset(Size::from_bytes(u64::try_from(name.len()).unwrap().checked_add(1).unwrap()), this)?)
Scalar::from(var_ptr.offset(Size::from_bytes(name.len()) + Size::from_bytes(1), this)?)
}
None => Scalar::ptr_null(&*this.tcx),
})
@ -187,7 +187,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
this.layout_of(tcx.mk_array(tcx.types.usize, u64::try_from(vars.len()).unwrap()))?;
let vars_place = this.allocate(vars_layout, MiriMemoryKind::Machine.into());
for (idx, var) in vars.into_iter().enumerate() {
let place = this.mplace_field(vars_place, u64::try_from(idx).unwrap())?;
let place = this.mplace_field(vars_place, idx)?;
this.write_scalar(var, place.into())?;
}
this.write_scalar(