@@ -1157,7 +1157,7 @@ macro_rules! integers {
11571157 fn linear_lift_from_memory( _cx: & mut LiftContext <' _>, ty: InterfaceType , bytes: & [ u8 ] ) -> Result <Self > {
11581158 debug_assert!( matches!( ty, InterfaceType :: $ty) ) ;
11591159 debug_assert!( ( bytes. as_ptr( ) as usize ) % Self :: SIZE32 == 0 ) ;
1160- Ok ( $primitive:: from_le_bytes( bytes. try_into ( ) . unwrap( ) ) )
1160+ Ok ( $primitive:: from_le_bytes( * bytes. as_array ( ) . unwrap( ) ) )
11611161 }
11621162
11631163 fn linear_lift_into_from_memory(
@@ -1257,8 +1257,9 @@ macro_rules! floats {
12571257 // into a memcpy on little-endian platforms.
12581258 // TODO use `as_chunks` when https://github.com/rust-lang/rust/issues/74985
12591259 // is stabilized
1260- for ( dst, src) in iter:: zip( dst. chunks_exact_mut( Self :: SIZE32 ) , items) {
1261- let dst: & mut [ u8 ; Self :: SIZE32 ] = dst. try_into( ) . unwrap( ) ;
1260+ let ( dst, rest) = dst. as_chunks_mut:: <{ Self :: SIZE32 } >( ) ;
1261+ debug_assert!( rest. is_empty( ) ) ;
1262+ for ( dst, src) in iter:: zip( dst, items) {
12621263 * dst = src. to_le_bytes( ) ;
12631264 }
12641265 Ok ( ( ) )
@@ -1276,7 +1277,7 @@ macro_rules! floats {
12761277 fn linear_lift_from_memory( _cx: & mut LiftContext <' _>, ty: InterfaceType , bytes: & [ u8 ] ) -> Result <Self > {
12771278 debug_assert!( matches!( ty, InterfaceType :: $ty) ) ;
12781279 debug_assert!( ( bytes. as_ptr( ) as usize ) % Self :: SIZE32 == 0 ) ;
1279- Ok ( $float:: from_le_bytes( bytes. try_into ( ) . unwrap( ) ) )
1280+ Ok ( $float:: from_le_bytes( * bytes. as_array ( ) . unwrap( ) ) )
12801281 }
12811282
12821283 fn linear_lift_list_from_memory( cx: & mut LiftContext <' _>, list: & WasmList <Self >) -> Result <Vec <Self >> where Self : Sized {
@@ -1295,7 +1296,7 @@ macro_rules! floats {
12951296 Ok (
12961297 bytes
12971298 . chunks_exact( Self :: SIZE32 )
1298- . map( |i| $float:: from_le_bytes( i . try_into ( ) . unwrap( ) ) )
1299+ . map( |i| $float:: from_le_bytes( * i . as_array ( ) . unwrap( ) ) )
12991300 . collect( )
13001301 )
13011302 }
@@ -1435,7 +1436,7 @@ unsafe impl Lift for char {
14351436 ) -> Result < Self > {
14361437 debug_assert ! ( matches!( ty, InterfaceType :: Char ) ) ;
14371438 debug_assert ! ( ( bytes. as_ptr( ) as usize ) % Self :: SIZE32 == 0 ) ;
1438- let bits = u32:: from_le_bytes ( bytes. try_into ( ) . unwrap ( ) ) ;
1439+ let bits = u32:: from_le_bytes ( * bytes. as_array ( ) . unwrap ( ) ) ;
14391440 Ok ( char:: try_from ( bits) ?)
14401441 }
14411442}
@@ -1454,8 +1455,8 @@ fn lift_pointer_pair_from_flat(
14541455fn lift_pointer_pair_from_memory ( cx : & mut LiftContext < ' _ > , bytes : & [ u8 ] ) -> Result < ( usize , usize ) > {
14551456 // FIXME(#4311): needs memory64 treatment
14561457 let _ = cx; // this will be needed for memory64 in the future
1457- let ptr = u32:: from_le_bytes ( bytes[ ..4 ] . try_into ( ) . unwrap ( ) ) ;
1458- let len = u32:: from_le_bytes ( bytes[ 4 ..] . try_into ( ) . unwrap ( ) ) ;
1458+ let ptr = u32:: from_le_bytes ( * bytes[ ..4 ] . as_array ( ) . unwrap ( ) ) ;
1459+ let len = u32:: from_le_bytes ( * bytes[ 4 ..] . as_array ( ) . unwrap ( ) ) ;
14591460 Ok ( ( usize:: try_from ( ptr) ?, usize:: try_from ( len) ?) )
14601461}
14611462
@@ -1769,14 +1770,13 @@ impl WasmStr {
17691770
17701771 fn decode_utf16 < ' a > ( & self , memory : & ' a [ u8 ] , len : usize ) -> Result < Cow < ' a , str > > {
17711772 // See notes in `decode_utf8` for why this is panicking indexing.
1772- let memory = & memory[ self . ptr ..] [ ..len * 2 ] ;
1773- Ok ( core:: char:: decode_utf16 (
1774- memory
1775- . chunks ( 2 )
1776- . map ( |chunk| u16:: from_le_bytes ( chunk. try_into ( ) . unwrap ( ) ) ) ,
1773+ let ( chunks, rest) = & memory[ self . ptr ..] [ ..len * 2 ] . as_chunks :: < 2 > ( ) ;
1774+ debug_assert ! ( rest. is_empty( ) ) ;
1775+ Ok (
1776+ core:: char:: decode_utf16 ( chunks. iter ( ) . map ( |chunk| u16:: from_le_bytes ( * chunk) ) )
1777+ . collect :: < Result < String , _ > > ( ) ?
1778+ . into ( ) ,
17771779 )
1778- . collect :: < Result < String , _ > > ( ) ?
1779- . into ( ) )
17801780 }
17811781
17821782 fn decode_latin1 < ' a > ( & self , memory : & ' a [ u8 ] ) -> Result < Cow < ' a , str > > {
0 commit comments