Skip to content

Commit b13d504

Browse files
committed
improve log when something no longer exists
1 parent 94acff1 commit b13d504

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

src/librustc_incremental/persist/directory.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ impl DefIdDirectory {
5353
DefIdDirectory { paths: vec![], krates: krates }
5454
}
5555

56+
fn max_current_crate(&self, tcx: TyCtxt) -> ast::CrateNum {
57+
tcx.sess.cstore.crates()
58+
.into_iter()
59+
.max()
60+
.unwrap_or(LOCAL_CRATE)
61+
}
62+
63+
/// Returns a string form for `index`; useful for debugging
64+
pub fn def_path_string(&self, tcx: TyCtxt, index: DefPathIndex) -> String {
65+
let path = &self.paths[index.index as usize];
66+
if self.krate_still_valid(tcx, self.max_current_crate(tcx), path.krate) {
67+
path.to_string(tcx)
68+
} else {
69+
format!("<crate {} changed>", path.krate)
70+
}
71+
}
72+
5673
pub fn krate_still_valid(&self,
5774
tcx: TyCtxt,
5875
max_current_crate: ast::CrateNum,
@@ -75,11 +92,7 @@ impl DefIdDirectory {
7592
}
7693

7794
pub fn retrace(&self, tcx: TyCtxt) -> RetracedDefIdDirectory {
78-
let max_current_crate =
79-
tcx.sess.cstore.crates()
80-
.into_iter()
81-
.max()
82-
.unwrap_or(LOCAL_CRATE);
95+
let max_current_crate = self.max_current_crate(tcx);
8396

8497
let ids = self.paths.iter()
8598
.map(|path| {

src/librustc_incremental/persist/load.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ pub fn decode_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
122122
// source is dirty, it removes it from that list and adds the
123123
// target to `dirty_nodes`. It stops when it reaches a fixed
124124
// point.
125-
let clean_edges = compute_clean_edges(&serialized_dep_graph.edges,
125+
let clean_edges = compute_clean_edges(tcx,
126+
&directory,
127+
&serialized_dep_graph.edges,
126128
&retraced,
127129
&mut dirty_nodes);
128130

@@ -190,7 +192,9 @@ fn initial_dirty_nodes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
190192
dirty_nodes
191193
}
192194

193-
fn compute_clean_edges(serialized_edges: &[(SerializedEdge)],
195+
fn compute_clean_edges(tcx: TyCtxt,
196+
directory: &DefIdDirectory,
197+
serialized_edges: &[(SerializedEdge)],
194198
retraced: &RetracedDefIdDirectory,
195199
dirty_nodes: &mut DirtyNodes)
196200
-> CleanEdges {
@@ -205,7 +209,11 @@ fn compute_clean_edges(serialized_edges: &[(SerializedEdge)],
205209
} else {
206210
// source removed, target must be dirty
207211
debug!("compute_clean_edges: {:?} dirty because {:?} no longer exists",
208-
target, serialized_source);
212+
target,
213+
serialized_source.map_def(|&index| {
214+
Some(directory.def_path_string(tcx, index))
215+
}).unwrap());
216+
209217
dirty_nodes.insert(target);
210218
}
211219
} else {

src/librustc_incremental/persist/save.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use rustc::hir::def_id::DefId;
1414
use rustc::middle::cstore::LOCAL_CRATE;
1515
use rustc::session::Session;
1616
use rustc::ty::TyCtxt;
17-
use rustc_data_structures::fnv::FnvHashMap;
1817
use rustc_serialize::{Encodable as RustcEncodable};
1918
use std::hash::{Hash, Hasher, SipHasher};
2019
use std::io::{self, Cursor, Write};

0 commit comments

Comments
 (0)