@@ -92,7 +92,7 @@ impl<Tag> Allocation<Tag> {
92
92
/// Creates a read-only allocation initialized by the given bytes
93
93
pub fn from_bytes < ' a > ( slice : impl Into < Cow < ' a , [ u8 ] > > , align : Align ) -> Self {
94
94
let bytes = slice. into ( ) . into_owned ( ) ;
95
- let size = Size :: from_bytes ( u64 :: try_from ( bytes. len ( ) ) . unwrap ( ) ) ;
95
+ let size = Size :: from_bytes ( bytes. len ( ) ) ;
96
96
Self {
97
97
bytes,
98
98
relocations : Relocations :: new ( ) ,
@@ -293,8 +293,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
293
293
let offset = usize:: try_from ( ptr. offset . bytes ( ) ) . unwrap ( ) ;
294
294
Ok ( match self . bytes [ offset..] . iter ( ) . position ( |& c| c == 0 ) {
295
295
Some ( size) => {
296
- let size_with_null =
297
- Size :: from_bytes ( u64:: try_from ( size. checked_add ( 1 ) . unwrap ( ) ) . unwrap ( ) ) ;
296
+ let size_with_null = Size :: from_bytes ( size. checked_add ( 1 ) . unwrap ( ) ) ;
298
297
// Go through `get_bytes` for checks and AllocationExtra hooks.
299
298
// We read the null, so we include it in the request, but we want it removed
300
299
// from the result, so we do subslicing.
@@ -339,7 +338,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
339
338
let ( lower, upper) = src. size_hint ( ) ;
340
339
let len = upper. expect ( "can only write bounded iterators" ) ;
341
340
assert_eq ! ( lower, len, "can only write iterators with a precise length" ) ;
342
- let bytes = self . get_bytes_mut ( cx, ptr, Size :: from_bytes ( u64 :: try_from ( len) . unwrap ( ) ) ) ?;
341
+ let bytes = self . get_bytes_mut ( cx, ptr, Size :: from_bytes ( len) ) ?;
343
342
// `zip` would stop when the first iterator ends; we want to definitely
344
343
// cover all of `bytes`.
345
344
for dest in bytes {
@@ -382,11 +381,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
382
381
} else {
383
382
match self . relocations . get ( & ptr. offset ) {
384
383
Some ( & ( tag, alloc_id) ) => {
385
- let ptr = Pointer :: new_with_tag (
386
- alloc_id,
387
- Size :: from_bytes ( u64:: try_from ( bits) . unwrap ( ) ) ,
388
- tag,
389
- ) ;
384
+ let ptr = Pointer :: new_with_tag ( alloc_id, Size :: from_bytes ( bits) , tag) ;
390
385
return Ok ( ScalarMaybeUndef :: Scalar ( ptr. into ( ) ) ) ;
391
386
}
392
387
None => { }
0 commit comments