File tree Expand file tree Collapse file tree 2 files changed +2
-8
lines changed
compiler/rustc_metadata/src/rmeta Expand file tree Collapse file tree 2 files changed +2
-8
lines changed Original file line number Diff line number Diff line change @@ -647,10 +647,7 @@ impl<'tcx> MetadataBlob {
647
647
crate fn get_root ( & self ) -> CrateRoot < ' tcx > {
648
648
let slice = & self . blob ( ) [ ..] ;
649
649
let offset = METADATA_HEADER . len ( ) ;
650
- let pos = ( ( ( slice[ offset + 0 ] as u32 ) << 24 )
651
- | ( ( slice[ offset + 1 ] as u32 ) << 16 )
652
- | ( ( slice[ offset + 2 ] as u32 ) << 8 )
653
- | ( ( slice[ offset + 3 ] as u32 ) << 0 ) ) as usize ;
650
+ let pos = ( u32:: from_le_bytes ( slice[ offset..offset + 4 ] . try_into ( ) . unwrap ( ) ) ) as usize ;
654
651
Lazy :: < CrateRoot < ' tcx > > :: from_position ( NonZeroUsize :: new ( pos) . unwrap ( ) ) . decode ( self )
655
652
}
656
653
Original file line number Diff line number Diff line change @@ -2214,10 +2214,7 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata {
2214
2214
// Encode the root position.
2215
2215
let header = METADATA_HEADER . len ( ) ;
2216
2216
let pos = root. position . get ( ) ;
2217
- result[ header + 0 ] = ( pos >> 24 ) as u8 ;
2218
- result[ header + 1 ] = ( pos >> 16 ) as u8 ;
2219
- result[ header + 2 ] = ( pos >> 8 ) as u8 ;
2220
- result[ header + 3 ] = ( pos >> 0 ) as u8 ;
2217
+ result[ header..header + 4 ] . copy_from_slice ( & pos. to_le_bytes ( ) ) ;
2221
2218
2222
2219
// Record metadata size for self-profiling
2223
2220
tcx. prof . artifact_size ( "crate_metadata" , "crate_metadata" , result. len ( ) as u64 ) ;
You can’t perform that action at this time.
0 commit comments