@@ -79,11 +79,6 @@ pub trait OnDiskCache<'tcx>: rustc_data_structures::sync::Sync {
7979 where
8080 Self : Sized ;
8181
82- /// Converts a `DefPathHash` to its corresponding `DefId` in the current compilation
83- /// session, if it still exists. This is used during incremental compilation to
84- /// turn a deserialized `DefPathHash` into its current `DefId`.
85- fn def_path_hash_to_def_id ( & self , tcx : TyCtxt < ' tcx > , def_path_hash : DefPathHash ) -> DefId ;
86-
8782 fn drop_serialized_data ( & self , tcx : TyCtxt < ' tcx > ) ;
8883
8984 fn serialize ( & self , tcx : TyCtxt < ' tcx > , encoder : & mut FileEncoder ) -> FileEncodeResult ;
@@ -1301,6 +1296,27 @@ impl<'tcx> TyCtxt<'tcx> {
13011296 }
13021297 }
13031298
1299+ /// Converts a `DefPathHash` to its corresponding `DefId` in the current compilation
1300+ /// session, if it still exists. This is used during incremental compilation to
1301+ /// turn a deserialized `DefPathHash` into its current `DefId`.
1302+ pub fn def_path_hash_to_def_id ( self , hash : DefPathHash ) -> DefId {
1303+ debug ! ( "def_path_hash_to_def_id({:?})" , hash) ;
1304+
1305+ let stable_crate_id = hash. stable_crate_id ( ) ;
1306+
1307+ // If this is a DefPathHash from the local crate, we can look up the
1308+ // DefId in the tcx's `Definitions`.
1309+ if stable_crate_id == self . sess . local_stable_crate_id ( ) {
1310+ self . untracked_resolutions . definitions . local_def_path_hash_to_def_id ( hash) . to_def_id ( )
1311+ } else {
1312+ // If this is a DefPathHash from an upstream crate, let the CrateStore map
1313+ // it to a DefId.
1314+ let cstore = & self . untracked_resolutions . cstore ;
1315+ let cnum = cstore. stable_crate_id_to_crate_num ( stable_crate_id) ;
1316+ cstore. def_path_hash_to_def_id ( cnum, hash)
1317+ }
1318+ }
1319+
13041320 pub fn def_path_debug_str ( self , def_id : DefId ) -> String {
13051321 // We are explicitly not going through queries here in order to get
13061322 // crate name and stable crate id since this code is called from debug!()
0 commit comments