Skip to content

Commit 0d0a457

Browse files
committed
Auto merge of #1262 - RalfJung:rustup, r=RalfJung
rustup; get rid of some try_from that are no longer needed
2 parents c6e8838 + 81d5056 commit 0d0a457

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
02046a5d402c789c006d0da7662f800fe3c45faf
1+
a5fb9ae5b2ed3cb011ada9dc1e8633aa0927f279

src/eval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
114114
ecx.layout_of(tcx.mk_array(tcx.mk_imm_ptr(tcx.types.u8), u64::try_from(argvs.len()).unwrap()))?;
115115
let argvs_place = ecx.allocate(argvs_layout, MiriMemoryKind::Machine.into());
116116
for (idx, arg) in argvs.into_iter().enumerate() {
117-
let place = ecx.mplace_field(argvs_place, u64::try_from(idx).unwrap())?;
117+
let place = ecx.mplace_field(argvs_place, idx)?;
118118
ecx.write_scalar(arg, place.into())?;
119119
}
120120
ecx.memory.mark_immutable(argvs_place.ptr.assert_ptr().alloc_id)?;
@@ -154,7 +154,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
154154
// Store the UTF-16 string. We just allocated so we know the bounds are fine.
155155
let char_size = Size::from_bytes(2);
156156
for (idx, &c) in cmd_utf16.iter().enumerate() {
157-
let place = ecx.mplace_field(cmd_place, u64::try_from(idx).unwrap())?;
157+
let place = ecx.mplace_field(cmd_place, idx)?;
158158
ecx.write_scalar(Scalar::from_uint(c, char_size), place.into())?;
159159
}
160160
}

src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
598598
// Store the UTF-16 string.
599599
let char_size = Size::from_bytes(2);
600600
for (idx, c) in u16_vec.into_iter().chain(iter::once(0x0000)).enumerate() {
601-
let place = this.mplace_field(mplace, u64::try_from(idx).unwrap())?;
601+
let place = this.mplace_field(mplace, idx)?;
602602
this.write_scalar(Scalar::from_uint(c, char_size), place.into())?;
603603
}
604604
Ok((true, string_length))

src/shims/env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
6161
Ok(match this.machine.env_vars.map.get(name) {
6262
// The offset is used to strip the "{name}=" part of the string.
6363
Some(var_ptr) => {
64-
Scalar::from(var_ptr.offset(Size::from_bytes(u64::try_from(name.len()).unwrap().checked_add(1).unwrap()), this)?)
64+
Scalar::from(var_ptr.offset(Size::from_bytes(name.len()) + Size::from_bytes(1), this)?)
6565
}
6666
None => Scalar::ptr_null(&*this.tcx),
6767
})
@@ -187,7 +187,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
187187
this.layout_of(tcx.mk_array(tcx.types.usize, u64::try_from(vars.len()).unwrap()))?;
188188
let vars_place = this.allocate(vars_layout, MiriMemoryKind::Machine.into());
189189
for (idx, var) in vars.into_iter().enumerate() {
190-
let place = this.mplace_field(vars_place, u64::try_from(idx).unwrap())?;
190+
let place = this.mplace_field(vars_place, idx)?;
191191
this.write_scalar(var, place.into())?;
192192
}
193193
this.write_scalar(

0 commit comments

Comments
 (0)