@@ -123,13 +123,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
123
123
}
124
124
hir:: PrimTy :: Int ( IntTy :: Isize ) => {
125
125
let x = call :: < isize > ( ptr, libffi_args. as_slice ( ) ) ;
126
- if isize:: BITS == 64 {
127
- this. write_int ( x as i64 , dest) ?;
128
- } else if usize:: BITS == 32 {
129
- this. write_int ( x as i32 , dest) ?;
130
- } else {
131
- panic ! ( "machine isize should be 32 or 64 bits" ) ;
132
- }
126
+ // `isize` doesn't `impl Into<i128>`, so convert manually.
127
+ // Convert to `i64` since this covers both 32- and 64-bit machines.
128
+ this. write_int ( i64:: try_from ( x) . unwrap ( ) , dest) ?;
133
129
return Ok ( ( ) ) ;
134
130
}
135
131
// uints
@@ -155,13 +151,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
155
151
}
156
152
hir:: PrimTy :: Uint ( UintTy :: Usize ) => {
157
153
let x = call :: < usize > ( ptr, libffi_args. as_slice ( ) ) ;
158
- if usize:: BITS == 64 {
159
- this. write_int ( x as u64 , dest) ?;
160
- } else if usize:: BITS == 32 {
161
- this. write_int ( x as u32 , dest) ?;
162
- } else {
163
- panic ! ( "machine usize should be 32 or 64 bits" ) ;
164
- }
154
+ // `usize` doesn't `impl Into<i128>`, so convert manually.
155
+ // Convert to `u64` since this covers both 32- and 64-bit machines.
156
+ this. write_int ( u64:: try_from ( x) . unwrap ( ) , dest) ?;
165
157
return Ok ( ( ) ) ;
166
158
}
167
159
_ => { }
0 commit comments