Skip to content

Commit cd8a352

Browse files
committed
Auto merge of #46427 - michaelwoerister:transitive-svh, r=nikomatsakis
incr.comp.: Incorporate the stable commandline arg hash and SVHs of upstream crates into the SVH. So far the SVH detected changes in the HIR, which is already very sensitive, but in order for `eval_always` queries to also be sensitive to changes in upstream crates, the SVH also needs to capture changes there. This PR fixes [rust-icci/crossbeam](https://travis-ci.org/rust-icci/crossbeam/builds/308936448), but I have not yet been able to come up with a minimal regression test. r? @nikomatsakis
2 parents 8503b3f + 8129c53 commit cd8a352

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/librustc/hir/map/collector.rs

+19-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use super::*;
1212

1313
use dep_graph::{DepGraph, DepKind, DepNodeIndex};
1414
use hir::intravisit::{Visitor, NestedVisitorMap};
15+
use middle::cstore::CrateStore;
1516
use session::CrateDisambiguator;
1617
use std::iter::repeat;
1718
use syntax::ast::{NodeId, CRATE_NODE_ID};
@@ -119,7 +120,9 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
119120
}
120121

121122
pub(super) fn finalize_and_compute_crate_hash(self,
122-
crate_disambiguator: CrateDisambiguator)
123+
crate_disambiguator: CrateDisambiguator,
124+
cstore: &CrateStore,
125+
commandline_args_hash: u64)
123126
-> Vec<MapEntry<'hir>> {
124127
let mut node_hashes: Vec<_> = self
125128
.hir_body_nodes
@@ -132,9 +135,23 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
132135

133136
node_hashes.sort_unstable_by(|&(ref d1, _), &(ref d2, _)| d1.cmp(d2));
134137

138+
let mut upstream_crates: Vec<_> = cstore.crates_untracked().iter().map(|&cnum| {
139+
let name = cstore.crate_name_untracked(cnum).as_str();
140+
let disambiguator = cstore.crate_disambiguator_untracked(cnum)
141+
.to_fingerprint();
142+
let hash = cstore.crate_hash_untracked(cnum);
143+
(name, disambiguator, hash)
144+
}).collect();
145+
146+
upstream_crates.sort_unstable_by(|&(name1, dis1, _), &(name2, dis2, _)| {
147+
(name1, dis1).cmp(&(name2, dis2))
148+
});
149+
135150
self.dep_graph.with_task(DepNode::new_no_params(DepKind::Krate),
136151
&self.hcx,
137-
(node_hashes, crate_disambiguator.to_fingerprint()),
152+
((node_hashes, upstream_crates),
153+
(commandline_args_hash,
154+
crate_disambiguator.to_fingerprint())),
138155
identity_fn);
139156
self.map
140157
}

src/librustc/hir/map/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,10 @@ pub fn map_crate<'hir>(sess: &::session::Session,
10591059
intravisit::walk_crate(&mut collector, &forest.krate);
10601060

10611061
let crate_disambiguator = sess.local_crate_disambiguator();
1062-
collector.finalize_and_compute_crate_hash(crate_disambiguator)
1062+
let cmdline_args = sess.opts.dep_tracking_hash();
1063+
collector.finalize_and_compute_crate_hash(crate_disambiguator,
1064+
cstore,
1065+
cmdline_args)
10631066
};
10641067

10651068
if log_enabled!(::log::LogLevel::Debug) {

0 commit comments

Comments
 (0)