improve log when something no longer exists

This commit is contained in:
Niko Matsakis 2016-08-02 19:11:46 -04:00
parent 94acff1803
commit b13d5041f6
3 changed files with 29 additions and 9 deletions

View file

@ -53,6 +53,23 @@ impl DefIdDirectory {
DefIdDirectory { paths: vec![], krates: krates }
}
fn max_current_crate(&self, tcx: TyCtxt) -> ast::CrateNum {
tcx.sess.cstore.crates()
.into_iter()
.max()
.unwrap_or(LOCAL_CRATE)
}
/// Returns a string form for `index`; useful for debugging
pub fn def_path_string(&self, tcx: TyCtxt, index: DefPathIndex) -> String {
let path = &self.paths[index.index as usize];
if self.krate_still_valid(tcx, self.max_current_crate(tcx), path.krate) {
path.to_string(tcx)
} else {
format!("<crate {} changed>", path.krate)
}
}
pub fn krate_still_valid(&self,
tcx: TyCtxt,
max_current_crate: ast::CrateNum,
@ -75,11 +92,7 @@ impl DefIdDirectory {
}
pub fn retrace(&self, tcx: TyCtxt) -> RetracedDefIdDirectory {
let max_current_crate =
tcx.sess.cstore.crates()
.into_iter()
.max()
.unwrap_or(LOCAL_CRATE);
let max_current_crate = self.max_current_crate(tcx);
let ids = self.paths.iter()
.map(|path| {

View file

@ -122,7 +122,9 @@ pub fn decode_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// source is dirty, it removes it from that list and adds the
// target to `dirty_nodes`. It stops when it reaches a fixed
// point.
let clean_edges = compute_clean_edges(&serialized_dep_graph.edges,
let clean_edges = compute_clean_edges(tcx,
&directory,
&serialized_dep_graph.edges,
&retraced,
&mut dirty_nodes);
@ -190,7 +192,9 @@ fn initial_dirty_nodes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
dirty_nodes
}
fn compute_clean_edges(serialized_edges: &[(SerializedEdge)],
fn compute_clean_edges(tcx: TyCtxt,
directory: &DefIdDirectory,
serialized_edges: &[(SerializedEdge)],
retraced: &RetracedDefIdDirectory,
dirty_nodes: &mut DirtyNodes)
-> CleanEdges {
@ -205,7 +209,11 @@ fn compute_clean_edges(serialized_edges: &[(SerializedEdge)],
} else {
// source removed, target must be dirty
debug!("compute_clean_edges: {:?} dirty because {:?} no longer exists",
target, serialized_source);
target,
serialized_source.map_def(|&index| {
Some(directory.def_path_string(tcx, index))
}).unwrap());
dirty_nodes.insert(target);
}
} else {

View file

@ -14,7 +14,6 @@ use rustc::hir::def_id::DefId;
use rustc::middle::cstore::LOCAL_CRATE;
use rustc::session::Session;
use rustc::ty::TyCtxt;
use rustc_data_structures::fnv::FnvHashMap;
use rustc_serialize::{Encodable as RustcEncodable};
use std::hash::{Hash, Hasher, SipHasher};
use std::io::{self, Cursor, Write};