@@ -78,10 +78,6 @@ pub(crate) struct CrateMetadata {
7878 blob : MetadataBlob ,
7979
8080 // --- 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.
8581 root : CrateRoot ,
8682 /// Trait impl data.
8783 /// FIXME: Used only from queries and can use query cache,
@@ -688,10 +684,10 @@ impl MetadataBlob {
688684 pub ( crate ) fn get_root ( & self ) -> CrateRoot {
689685 let slice = & self . blob ( ) [ ..] ;
690686 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+
695691 LazyValue :: < CrateRoot > :: from_position ( NonZeroUsize :: new ( pos) . unwrap ( ) ) . decode ( self )
696692 }
697693
@@ -702,16 +698,14 @@ impl MetadataBlob {
702698 writeln ! ( out, "hash {} stable_crate_id {:?}" , root. hash, root. stable_crate_id) ?;
703699 writeln ! ( out, "proc_macro {:?}" , root. proc_macro_data. is_some( ) ) ?;
704700 writeln ! ( out, "=External Dependencies=" ) ?;
701+
705702 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+
706706 writeln ! (
707707 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:?}"
715709 ) ?;
716710 }
717711 write ! ( out, "\n " ) ?;
0 commit comments