rustc: Move crate_hash to a query
This commit is contained in:
parent
ebc1fd321d
commit
d6c88f4936
@ -540,6 +540,7 @@ define_dep_nodes!( <'tcx>
|
|||||||
[] PluginRegistrarFn(CrateNum),
|
[] PluginRegistrarFn(CrateNum),
|
||||||
[] DeriveRegistrarFn(CrateNum),
|
[] DeriveRegistrarFn(CrateNum),
|
||||||
[] CrateDisambiguator(CrateNum),
|
[] CrateDisambiguator(CrateNum),
|
||||||
|
[] CrateHash(CrateNum),
|
||||||
);
|
);
|
||||||
|
|
||||||
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
|
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
|
||||||
|
@ -253,7 +253,6 @@ pub trait CrateStore {
|
|||||||
fn crate_name(&self, cnum: CrateNum) -> Symbol;
|
fn crate_name(&self, cnum: CrateNum) -> Symbol;
|
||||||
/// The name of the crate as it is stored in the crate's metadata.
|
/// The name of the crate as it is stored in the crate's metadata.
|
||||||
fn original_crate_name(&self, cnum: CrateNum) -> Symbol;
|
fn original_crate_name(&self, cnum: CrateNum) -> Symbol;
|
||||||
fn crate_hash(&self, cnum: CrateNum) -> Svh;
|
|
||||||
|
|
||||||
// resolve
|
// resolve
|
||||||
fn def_key(&self, def: DefId) -> DefKey;
|
fn def_key(&self, def: DefId) -> DefKey;
|
||||||
@ -353,7 +352,6 @@ impl CrateStore for DummyCrateStore {
|
|||||||
fn original_crate_name(&self, cnum: CrateNum) -> Symbol {
|
fn original_crate_name(&self, cnum: CrateNum) -> Symbol {
|
||||||
bug!("original_crate_name")
|
bug!("original_crate_name")
|
||||||
}
|
}
|
||||||
fn crate_hash(&self, cnum: CrateNum) -> Svh { bug!("crate_hash") }
|
|
||||||
|
|
||||||
// resolve
|
// resolve
|
||||||
fn def_key(&self, def: DefId) -> DefKey { bug!("def_key") }
|
fn def_key(&self, def: DefId) -> DefKey { bug!("def_key") }
|
||||||
|
@ -13,6 +13,7 @@ use errors::{Diagnostic, DiagnosticBuilder};
|
|||||||
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||||
use hir::def::{Def, Export};
|
use hir::def::{Def, Export};
|
||||||
use hir::{self, TraitCandidate, HirId};
|
use hir::{self, TraitCandidate, HirId};
|
||||||
|
use hir::svh::Svh;
|
||||||
use lint;
|
use lint;
|
||||||
use middle::const_val;
|
use middle::const_val;
|
||||||
use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary};
|
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
|
// If enabled, send a message to the profile-queries thread
|
||||||
macro_rules! profq_msg {
|
macro_rules! profq_msg {
|
||||||
($tcx:expr, $msg:expr) => {
|
($tcx:expr, $msg:expr) => {
|
||||||
@ -1198,6 +1205,7 @@ define_maps! { <'tcx>
|
|||||||
[] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
|
[] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
|
||||||
[] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option<DefId>,
|
[] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option<DefId>,
|
||||||
[] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> Symbol,
|
[] 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> {
|
fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {
|
||||||
|
@ -632,7 +632,7 @@ pub fn find_metadata_hashes_for(tcx: TyCtxt, cnum: CrateNum) -> Option<PathBuf>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 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| {
|
let sub_dir = find_metadata_hashes_iter(&target_svh, dir_entries.filter_map(|e| {
|
||||||
|
@ -133,7 +133,7 @@ impl<'a, 'tcx> HashContext<'a, 'tcx> {
|
|||||||
fn load_data(&mut self, cnum: CrateNum) {
|
fn load_data(&mut self, cnum: CrateNum) {
|
||||||
debug!("load_data(cnum={})", cnum);
|
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);
|
let old = self.crate_hashes.insert(cnum, svh);
|
||||||
debug!("load_data: svh={}", svh);
|
debug!("load_data: svh={}", svh);
|
||||||
assert!(old.is_none(), "loaded data for crate {:?} twice", cnum);
|
assert!(old.is_none(), "loaded data for crate {:?} twice", cnum);
|
||||||
|
@ -126,10 +126,6 @@ impl CStore {
|
|||||||
self.metas.borrow().get(&cnum).unwrap().clone()
|
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<CrateMetadata>) {
|
pub fn set_crate_data(&self, cnum: CrateNum, data: Rc<CrateMetadata>) {
|
||||||
self.metas.borrow_mut().insert(cnum, data);
|
self.metas.borrow_mut().insert(cnum, data);
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,6 @@ provide! { <'tcx> tcx, def_id, cdata,
|
|||||||
}
|
}
|
||||||
crate_disambiguator => { cdata.disambiguator() }
|
crate_disambiguator => { cdata.disambiguator() }
|
||||||
crate_hash => { cdata.hash() }
|
crate_hash => { cdata.hash() }
|
||||||
original_crate_name => { cdata.name() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) {
|
pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) {
|
||||||
@ -286,11 +285,6 @@ impl CrateStore for cstore::CStore {
|
|||||||
self.get_crate_data(cnum).name()
|
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
|
/// Returns the `DefKey` for a given `DefId`. This indicates the
|
||||||
/// parent `DefId` as well as some idea of what kind of data the
|
/// parent `DefId` as well as some idea of what kind of data the
|
||||||
/// `DefId` refers to.
|
/// `DefId` refers to.
|
||||||
|
@ -1296,7 +1296,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
|
|||||||
.map(|&cnum| {
|
.map(|&cnum| {
|
||||||
let dep = CrateDep {
|
let dep = CrateDep {
|
||||||
name: cstore.original_crate_name(cnum),
|
name: cstore.original_crate_name(cnum),
|
||||||
hash: cstore.crate_hash(cnum),
|
hash: self.tcx.crate_hash(cnum),
|
||||||
kind: cstore.dep_kind(cnum),
|
kind: cstore.dep_kind(cnum),
|
||||||
};
|
};
|
||||||
(cnum, dep)
|
(cnum, dep)
|
||||||
|
Loading…
Reference in New Issue
Block a user