Skip to content

Commit 2a5d89f

Browse files
committed
rustc: Move crate_hash to a query
1 parent f75be96 commit 2a5d89f

File tree

8 files changed

+12
-16
lines changed

8 files changed

+12
-16
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ define_dep_nodes!( <'tcx>
536536
[] PluginRegistrarFn(CrateNum),
537537
[] DeriveRegistrarFn(CrateNum),
538538
[] CrateDisambiguator(CrateNum),
539+
[] CrateHash(CrateNum),
539540
);
540541

541542
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {

src/librustc/middle/cstore.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ pub trait CrateStore {
253253
fn crate_name(&self, cnum: CrateNum) -> Symbol;
254254
/// The name of the crate as it is stored in the crate's metadata.
255255
fn original_crate_name(&self, cnum: CrateNum) -> Symbol;
256-
fn crate_hash(&self, cnum: CrateNum) -> Svh;
257256

258257
// resolve
259258
fn def_key(&self, def: DefId) -> DefKey;
@@ -353,7 +352,6 @@ impl CrateStore for DummyCrateStore {
353352
fn original_crate_name(&self, cnum: CrateNum) -> Symbol {
354353
bug!("original_crate_name")
355354
}
356-
fn crate_hash(&self, cnum: CrateNum) -> Svh { bug!("crate_hash") }
357355

358356
// resolve
359357
fn def_key(&self, def: DefId) -> DefKey { bug!("def_key") }

src/librustc/ty/maps.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use dep_graph::{DepConstructor, DepNode, DepNodeIndex};
1212
use errors::{Diagnostic, DiagnosticBuilder};
1313
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
1414
use hir::def::Def;
15+
use hir::svh::Svh;
1516
use hir;
1617
use lint;
1718
use middle::const_val;
@@ -589,6 +590,12 @@ impl<'tcx> QueryDescription for queries::crate_disambiguator<'tcx> {
589590
}
590591
}
591592

593+
impl<'tcx> QueryDescription for queries::crate_hash<'tcx> {
594+
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
595+
format!("looking up the hash a crate")
596+
}
597+
}
598+
592599
// If enabled, send a message to the profile-queries thread
593600
macro_rules! profq_msg {
594601
($tcx:expr, $msg:expr) => {
@@ -1167,6 +1174,7 @@ define_maps! { <'tcx>
11671174
[] plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
11681175
[] derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option<DefId>,
11691176
[] crate_disambiguator: CrateDisambiguator(CrateNum) -> Symbol,
1177+
[] crate_hash: CrateHash(CrateNum) -> Svh,
11701178
}
11711179

11721180
fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {

src/librustc_incremental/persist/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ pub fn find_metadata_hashes_for(tcx: TyCtxt, cnum: CrateNum) -> Option<PathBuf>
632632
}
633633
};
634634

635-
let target_svh = tcx.sess.cstore.crate_hash(cnum);
635+
let target_svh = tcx.crate_hash(cnum);
636636
let target_svh = base_n::encode(target_svh.as_u64(), INT_ENCODE_BASE);
637637

638638
let sub_dir = find_metadata_hashes_iter(&target_svh, dir_entries.filter_map(|e| {

src/librustc_incremental/persist/hash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<'a, 'tcx> HashContext<'a, 'tcx> {
133133
fn load_data(&mut self, cnum: CrateNum) {
134134
debug!("load_data(cnum={})", cnum);
135135

136-
let svh = self.tcx.sess.cstore.crate_hash(cnum);
136+
let svh = self.tcx.crate_hash(cnum);
137137
let old = self.crate_hashes.insert(cnum, svh);
138138
debug!("load_data: svh={}", svh);
139139
assert!(old.is_none(), "loaded data for crate {:?} twice", cnum);

src/librustc_metadata/cstore.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@ impl CStore {
126126
self.metas.borrow().get(&cnum).unwrap().clone()
127127
}
128128

129-
pub fn get_crate_hash(&self, cnum: CrateNum) -> Svh {
130-
self.get_crate_data(cnum).hash()
131-
}
132-
133129
pub fn set_crate_data(&self, cnum: CrateNum, data: Rc<CrateMetadata>) {
134130
self.metas.borrow_mut().insert(cnum, data);
135131
}

src/librustc_metadata/cstore_impl.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ use syntax::ext::base::SyntaxExtension;
3737
use syntax::parse::filemap_to_stream;
3838
use syntax::symbol::Symbol;
3939
use syntax_pos::{Span, NO_EXPANSION};
40-
use rustc::hir::svh::Svh;
4140
use rustc::hir;
4241

4342
macro_rules! provide {
@@ -174,7 +173,6 @@ provide! { <'tcx> tcx, def_id, cdata,
174173
}
175174
crate_disambiguator => { cdata.disambiguator() }
176175
crate_hash => { cdata.hash() }
177-
original_crate_name => { cdata.name() }
178176
}
179177

180178
pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) {
@@ -283,11 +281,6 @@ impl CrateStore for cstore::CStore {
283281
self.get_crate_data(cnum).name()
284282
}
285283

286-
fn crate_hash(&self, cnum: CrateNum) -> Svh
287-
{
288-
self.get_crate_hash(cnum)
289-
}
290-
291284
/// Returns the `DefKey` for a given `DefId`. This indicates the
292285
/// parent `DefId` as well as some idea of what kind of data the
293286
/// `DefId` refers to.

src/librustc_metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
12951295
.map(|&cnum| {
12961296
let dep = CrateDep {
12971297
name: cstore.original_crate_name(cnum),
1298-
hash: cstore.crate_hash(cnum),
1298+
hash: self.tcx.crate_hash(cnum),
12991299
kind: cstore.dep_kind(cnum),
13001300
};
13011301
(cnum, dep)

0 commit comments

Comments
 (0)