@@ -78,10 +78,6 @@ pub(crate) struct CrateMetadata {
78
78
blob : MetadataBlob ,
79
79
80
80
// --- Some data pre-decoded from the metadata blob, usually for performance ---
81
- /// NOTE(eddyb) we pass `'static` to a `'tcx` parameter because this
82
- /// lifetime is only used behind `LazyValue`, `LazyArray`, or `LazyTable`, and therefore acts like a
83
- /// universal (`for<'tcx>`), that is paired up with whichever `TyCtxt`
84
- /// is being used to decode those values.
85
81
root : CrateRoot ,
86
82
/// Trait impl data.
87
83
/// FIXME: Used only from queries and can use query cache,
@@ -688,10 +684,10 @@ impl MetadataBlob {
688
684
pub ( crate ) fn get_root ( & self ) -> CrateRoot {
689
685
let slice = & self . blob ( ) [ ..] ;
690
686
let offset = METADATA_HEADER . len ( ) ;
691
- let pos = ( ( ( slice [ offset + 0 ] as u32 ) << 24 )
692
- | ( ( slice[ offset + 1 ] as u32 ) << 16 )
693
- | ( ( slice [ offset + 2 ] as u32 ) << 8 )
694
- | ( ( slice [ offset + 3 ] as u32 ) << 0 ) ) as usize ;
687
+
688
+ let pos_bytes = slice[ offset.. ] [ .. 4 ] . try_into ( ) . unwrap ( ) ;
689
+ let pos = u32 :: from_be_bytes ( pos_bytes ) as usize ;
690
+
695
691
LazyValue :: < CrateRoot > :: from_position ( NonZeroUsize :: new ( pos) . unwrap ( ) ) . decode ( self )
696
692
}
697
693
@@ -702,16 +698,14 @@ impl MetadataBlob {
702
698
writeln ! ( out, "hash {} stable_crate_id {:?}" , root. hash, root. stable_crate_id) ?;
703
699
writeln ! ( out, "proc_macro {:?}" , root. proc_macro_data. is_some( ) ) ?;
704
700
writeln ! ( out, "=External Dependencies=" ) ?;
701
+
705
702
for ( i, dep) in root. crate_deps . decode ( self ) . enumerate ( ) {
703
+ let CrateDep { name, extra_filename, hash, host_hash, kind } = dep;
704
+ let number = i + 1 ;
705
+
706
706
writeln ! (
707
707
out,
708
- "{} {}{} hash {} host_hash {:?} kind {:?}" ,
709
- i + 1 ,
710
- dep. name,
711
- dep. extra_filename,
712
- dep. hash,
713
- dep. host_hash,
714
- dep. kind
708
+ "{number} {name}{extra_filename} hash {hash} host_hash {host_hash:?} kind {kind:?}"
715
709
) ?;
716
710
}
717
711
write ! ( out, "\n " ) ?;
0 commit comments