11// Decoding metadata from a single crate's metadata
22
3- use crate :: creader:: CrateMetadataRef ;
3+ use crate :: creader:: { CStore , CrateMetadataRef } ;
44use crate :: rmeta:: table:: { FixedSizeEncoding , Table } ;
55use crate :: rmeta:: * ;
66
@@ -1737,6 +1737,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
17371737impl CrateMetadata {
17381738 crate fn new (
17391739 sess : & Session ,
1740+ cstore : & CStore ,
17401741 blob : MetadataBlob ,
17411742 root : CrateRoot < ' static > ,
17421743 raw_proc_macros : Option < & ' static [ ProcMacro ] > ,
@@ -1752,11 +1753,6 @@ impl CrateMetadata {
17521753 . decode ( ( & blob, sess) )
17531754 . map ( |trait_impls| ( trait_impls. trait_id , trait_impls. impls ) )
17541755 . collect ( ) ;
1755- let incoherent_impls = root
1756- . incoherent_impls
1757- . decode ( ( & blob, sess) )
1758- . map ( |incoherent_impls| ( incoherent_impls. self_ty , incoherent_impls. impls ) )
1759- . collect ( ) ;
17601756 let alloc_decoding_state =
17611757 AllocDecodingState :: new ( root. interpret_alloc_index . decode ( & blob) . collect ( ) ) ;
17621758 let dependencies = Lock :: new ( cnum_map. iter ( ) . cloned ( ) . collect ( ) ) ;
@@ -1765,11 +1761,11 @@ impl CrateMetadata {
17651761 // that does not copy any data. It just does some data verification.
17661762 let def_path_hash_map = root. def_path_hash_map . decode ( & blob) ;
17671763
1768- CrateMetadata {
1764+ let mut cdata = CrateMetadata {
17691765 blob,
17701766 root,
17711767 trait_impls,
1772- incoherent_impls,
1768+ incoherent_impls : Default :: default ( ) ,
17731769 raw_proc_macros,
17741770 source_map_import_info : OnceCell :: new ( ) ,
17751771 def_path_hash_map,
@@ -1786,7 +1782,17 @@ impl CrateMetadata {
17861782 hygiene_context : Default :: default ( ) ,
17871783 def_key_cache : Default :: default ( ) ,
17881784 def_path_hash_cache : Default :: default ( ) ,
1789- }
1785+ } ;
1786+
1787+ // Need `CrateMetadataRef` to decode `DefId`s in simplified types.
1788+ cdata. incoherent_impls = cdata
1789+ . root
1790+ . incoherent_impls
1791+ . decode ( CrateMetadataRef { cdata : & cdata, cstore } )
1792+ . map ( |incoherent_impls| ( incoherent_impls. self_ty , incoherent_impls. impls ) )
1793+ . collect ( ) ;
1794+
1795+ cdata
17901796 }
17911797
17921798 crate fn dependencies ( & self ) -> LockGuard < ' _ , Vec < CrateNum > > {
0 commit comments