diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index e397ecbed79..5c574205fe8 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -540,6 +540,7 @@ define_dep_nodes!( <'tcx> [] PluginRegistrarFn(CrateNum), [] DeriveRegistrarFn(CrateNum), [] CrateDisambiguator(CrateNum), + [] CrateHash(CrateNum), ); trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug { diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 1f05edb86dc..d7b32abbcd2 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -253,7 +253,6 @@ pub trait CrateStore { fn crate_name(&self, cnum: CrateNum) -> Symbol; /// The name of the crate as it is stored in the crate's metadata. fn original_crate_name(&self, cnum: CrateNum) -> Symbol; - fn crate_hash(&self, cnum: CrateNum) -> Svh; // resolve fn def_key(&self, def: DefId) -> DefKey; @@ -353,7 +352,6 @@ impl CrateStore for DummyCrateStore { fn original_crate_name(&self, cnum: CrateNum) -> Symbol { bug!("original_crate_name") } - fn crate_hash(&self, cnum: CrateNum) -> Svh { bug!("crate_hash") } // resolve fn def_key(&self, def: DefId) -> DefKey { bug!("def_key") } diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index edfe806e613..48fca7e643b 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -13,6 +13,7 @@ use errors::{Diagnostic, DiagnosticBuilder}; use hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; use hir::def::{Def, Export}; use hir::{self, TraitCandidate, HirId}; +use hir::svh::Svh; use lint; use middle::const_val; use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary}; @@ -617,6 +618,12 @@ impl<'tcx> QueryDescription for queries::crate_disambiguator<'tcx> { } } +impl<'tcx> QueryDescription for queries::crate_hash<'tcx> { + fn describe(_tcx: TyCtxt, _: CrateNum) -> String { + format!("looking up the hash a crate") + } +} + // If enabled, send a message to the profile-queries thread macro_rules! profq_msg { ($tcx:expr, $msg:expr) => { @@ -1198,6 +1205,7 @@ define_maps! { <'tcx> [] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option, [] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option, [] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> Symbol, + [] fn crate_hash: CrateHash(CrateNum) -> Svh, } fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> { diff --git a/src/librustc_incremental/persist/fs.rs b/src/librustc_incremental/persist/fs.rs index 28d33d95286..434c82095bd 100644 --- a/src/librustc_incremental/persist/fs.rs +++ b/src/librustc_incremental/persist/fs.rs @@ -632,7 +632,7 @@ pub fn find_metadata_hashes_for(tcx: TyCtxt, cnum: CrateNum) -> Option } }; - let target_svh = tcx.sess.cstore.crate_hash(cnum); + let target_svh = tcx.crate_hash(cnum); let target_svh = base_n::encode(target_svh.as_u64(), INT_ENCODE_BASE); let sub_dir = find_metadata_hashes_iter(&target_svh, dir_entries.filter_map(|e| { diff --git a/src/librustc_incremental/persist/hash.rs b/src/librustc_incremental/persist/hash.rs index 9d762a74bfe..44d6788c773 100644 --- a/src/librustc_incremental/persist/hash.rs +++ b/src/librustc_incremental/persist/hash.rs @@ -133,7 +133,7 @@ impl<'a, 'tcx> HashContext<'a, 'tcx> { fn load_data(&mut self, cnum: CrateNum) { debug!("load_data(cnum={})", cnum); - let svh = self.tcx.sess.cstore.crate_hash(cnum); + let svh = self.tcx.crate_hash(cnum); let old = self.crate_hashes.insert(cnum, svh); debug!("load_data: svh={}", svh); assert!(old.is_none(), "loaded data for crate {:?} twice", cnum); diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index 0ed8ab2bc55..1933949e922 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -126,10 +126,6 @@ impl CStore { self.metas.borrow().get(&cnum).unwrap().clone() } - pub fn get_crate_hash(&self, cnum: CrateNum) -> Svh { - self.get_crate_data(cnum).hash() - } - pub fn set_crate_data(&self, cnum: CrateNum, data: Rc) { self.metas.borrow_mut().insert(cnum, data); } diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 3917318f67c..12f9b9f07b3 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -177,7 +177,6 @@ provide! { <'tcx> tcx, def_id, cdata, } crate_disambiguator => { cdata.disambiguator() } crate_hash => { cdata.hash() } - original_crate_name => { cdata.name() } } pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) { @@ -286,11 +285,6 @@ impl CrateStore for cstore::CStore { self.get_crate_data(cnum).name() } - fn crate_hash(&self, cnum: CrateNum) -> Svh - { - self.get_crate_hash(cnum) - } - /// Returns the `DefKey` for a given `DefId`. This indicates the /// parent `DefId` as well as some idea of what kind of data the /// `DefId` refers to. diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index d36aebe38eb..777e0f20827 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -1296,7 +1296,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { .map(|&cnum| { let dep = CrateDep { name: cstore.original_crate_name(cnum), - hash: cstore.crate_hash(cnum), + hash: self.tcx.crate_hash(cnum), kind: cstore.dep_kind(cnum), }; (cnum, dep)