This repository was archived by the owner on May 28, 2025. It is now read-only.
  
  
  
  
    
    
    
      
    
  
  
    
File tree Expand file tree Collapse file tree 4 files changed +18
-13
lines changed 
rustc_metadata/src/rmeta/decoder Expand file tree Collapse file tree 4 files changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -650,14 +650,18 @@ impl CrateStore for CStore {
650650    fn  def_path_hash ( & self ,  def :  DefId )  -> DefPathHash  { 
651651        self . get_crate_data ( def. krate ) . def_path_hash ( def. index ) 
652652    } 
653- 
654-     fn  def_path_hash_to_def_id ( & self ,  cnum :  CrateNum ,  hash :  DefPathHash )  -> DefId  { 
655-         let  def_index = self . get_crate_data ( cnum) . def_path_hash_to_def_index ( hash) ; 
656-         DefId  {  krate :  cnum,  index :  def_index } 
657-     } 
658653} 
659654
660655fn  provide_cstore_hooks ( providers :  & mut  Providers )  { 
656+     providers. hooks . def_path_hash_to_def_id_extern  = |tcx,  hash,  stable_crate_id| { 
657+         // If this is a DefPathHash from an upstream crate, let the CrateStore map 
658+         // it to a DefId. 
659+         let  cstore = CStore :: from_tcx ( tcx. tcx ) ; 
660+         let  cnum = cstore. stable_crate_id_to_crate_num ( stable_crate_id) ; 
661+         let  def_index = cstore. get_crate_data ( cnum) . def_path_hash_to_def_index ( hash) ; 
662+         DefId  {  krate :  cnum,  index :  def_index } 
663+     } ; 
664+ 
661665    providers. hooks . expn_hash_to_expn_id  = |tcx,  cnum,  index_guess,  hash| { 
662666        let  cstore = CStore :: from_tcx ( tcx. tcx ) ; 
663667        cstore. get_crate_data ( cnum) . expn_hash_to_expn_id ( tcx. sess ,  index_guess,  hash) 
Original file line number Diff line number Diff line change 66use  crate :: mir; 
77use  crate :: query:: TyCtxtAt ; 
88use  crate :: ty:: { Ty ,  TyCtxt } ; 
9+ use  rustc_hir:: def_id:: { DefId ,  DefPathHash } ; 
10+ use  rustc_session:: StableCrateId ; 
911use  rustc_span:: def_id:: { CrateNum ,  LocalDefId } ; 
1012use  rustc_span:: { ExpnHash ,  ExpnId ,  DUMMY_SP } ; 
1113
@@ -94,4 +96,10 @@ declare_hooks! {
9496        index_guess:  u32 , 
9597        hash:  ExpnHash 
9698    )  -> ExpnId ; 
99+ 
100+     /// Converts a `DefPathHash` to its corresponding `DefId` in the current compilation 
101+ /// session, if it still exists. This is used during incremental compilation to 
102+ /// turn a deserialized `DefPathHash` into its current `DefId`. 
103+ /// Will fetch a DefId from a DefPathHash for a foreign crate. 
104+ ( hash:  DefPathHash ,  stable_crate_id:  StableCrateId )  -> DefId ; 
97105} 
Original file line number Diff line number Diff line change @@ -1073,11 +1073,7 @@ impl<'tcx> TyCtxt<'tcx> {
10731073        if  stable_crate_id == self . stable_crate_id ( LOCAL_CRATE )  { 
10741074            self . untracked . definitions . read ( ) . local_def_path_hash_to_def_id ( hash,  err) . to_def_id ( ) 
10751075        }  else  { 
1076-             // If this is a DefPathHash from an upstream crate, let the CrateStore map 
1077-             // it to a DefId. 
1078-             let  cstore = & * self . cstore_untracked ( ) ; 
1079-             let  cnum = cstore. stable_crate_id_to_crate_num ( stable_crate_id) ; 
1080-             cstore. def_path_hash_to_def_id ( cnum,  hash) 
1076+             self . def_path_hash_to_def_id_extern ( hash,  stable_crate_id) 
10811077        } 
10821078    } 
10831079
Original file line number Diff line number Diff line change @@ -218,9 +218,6 @@ pub trait CrateStore: std::fmt::Debug {
218218    fn  crate_name ( & self ,  cnum :  CrateNum )  -> Symbol ; 
219219    fn  stable_crate_id ( & self ,  cnum :  CrateNum )  -> StableCrateId ; 
220220    fn  stable_crate_id_to_crate_num ( & self ,  stable_crate_id :  StableCrateId )  -> CrateNum ; 
221- 
222-     /// Fetch a DefId from a DefPathHash for a foreign crate. 
223- fn  def_path_hash_to_def_id ( & self ,  cnum :  CrateNum ,  hash :  DefPathHash )  -> DefId ; 
224221} 
225222
226223pub  type  CrateStoreDyn  = dyn  CrateStore  + sync:: DynSync  + sync:: DynSend ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments