@@ -92,7 +92,7 @@ impl<Tag> Allocation<Tag> {
9292 /// Creates a read-only allocation initialized by the given bytes
9393 pub fn from_bytes < ' a > ( slice : impl Into < Cow < ' a , [ u8 ] > > , align : Align ) -> Self {
9494 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 ( ) ) ;
9696 Self {
9797 bytes,
9898 relocations : Relocations :: new ( ) ,
@@ -293,8 +293,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
293293 let offset = usize:: try_from ( ptr. offset . bytes ( ) ) . unwrap ( ) ;
294294 Ok ( match self . bytes [ offset..] . iter ( ) . position ( |& c| c == 0 ) {
295295 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 ( ) ) ;
298297 // Go through `get_bytes` for checks and AllocationExtra hooks.
299298 // We read the null, so we include it in the request, but we want it removed
300299 // from the result, so we do subslicing.
@@ -339,7 +338,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
339338 let ( lower, upper) = src. size_hint ( ) ;
340339 let len = upper. expect ( "can only write bounded iterators" ) ;
341340 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) ) ?;
343342 // `zip` would stop when the first iterator ends; we want to definitely
344343 // cover all of `bytes`.
345344 for dest in bytes {
@@ -382,11 +381,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
382381 } else {
383382 match self . relocations . get ( & ptr. offset ) {
384383 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) ;
390385 return Ok ( ScalarMaybeUndef :: Scalar ( ptr. into ( ) ) ) ;
391386 }
392387 None => { }
0 commit comments