1
1
// Decoding metadata from a single crate's metadata
2
2
3
- use crate :: creader:: CrateMetadataRef ;
3
+ use crate :: creader:: { CStore , CrateMetadataRef } ;
4
4
use crate :: rmeta:: table:: { FixedSizeEncoding , Table } ;
5
5
use crate :: rmeta:: * ;
6
6
@@ -1737,6 +1737,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1737
1737
impl CrateMetadata {
1738
1738
crate fn new (
1739
1739
sess : & Session ,
1740
+ cstore : & CStore ,
1740
1741
blob : MetadataBlob ,
1741
1742
root : CrateRoot < ' static > ,
1742
1743
raw_proc_macros : Option < & ' static [ ProcMacro ] > ,
@@ -1752,11 +1753,6 @@ impl CrateMetadata {
1752
1753
. decode ( ( & blob, sess) )
1753
1754
. map ( |trait_impls| ( trait_impls. trait_id , trait_impls. impls ) )
1754
1755
. 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 ( ) ;
1760
1756
let alloc_decoding_state =
1761
1757
AllocDecodingState :: new ( root. interpret_alloc_index . decode ( & blob) . collect ( ) ) ;
1762
1758
let dependencies = Lock :: new ( cnum_map. iter ( ) . cloned ( ) . collect ( ) ) ;
@@ -1765,11 +1761,11 @@ impl CrateMetadata {
1765
1761
// that does not copy any data. It just does some data verification.
1766
1762
let def_path_hash_map = root. def_path_hash_map . decode ( & blob) ;
1767
1763
1768
- CrateMetadata {
1764
+ let mut cdata = CrateMetadata {
1769
1765
blob,
1770
1766
root,
1771
1767
trait_impls,
1772
- incoherent_impls,
1768
+ incoherent_impls : Default :: default ( ) ,
1773
1769
raw_proc_macros,
1774
1770
source_map_import_info : OnceCell :: new ( ) ,
1775
1771
def_path_hash_map,
@@ -1786,7 +1782,17 @@ impl CrateMetadata {
1786
1782
hygiene_context : Default :: default ( ) ,
1787
1783
def_key_cache : Default :: default ( ) ,
1788
1784
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
1790
1796
}
1791
1797
1792
1798
crate fn dependencies ( & self ) -> LockGuard < ' _ , Vec < CrateNum > > {
0 commit comments