From b13d5041f65df03bd3a34070cb08d339fa629f18 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 2 Aug 2016 19:11:46 -0400 Subject: [PATCH] improve log when something no longer exists --- src/librustc_incremental/persist/directory.rs | 23 +++++++++++++++---- src/librustc_incremental/persist/load.rs | 14 ++++++++--- src/librustc_incremental/persist/save.rs | 1 - 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/librustc_incremental/persist/directory.rs b/src/librustc_incremental/persist/directory.rs index 85aa9d28e5f2..61c14adb3a0e 100644 --- a/src/librustc_incremental/persist/directory.rs +++ b/src/librustc_incremental/persist/directory.rs @@ -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!("", 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| { diff --git a/src/librustc_incremental/persist/load.rs b/src/librustc_incremental/persist/load.rs index b47f2221e566..793a0466c315 100644 --- a/src/librustc_incremental/persist/load.rs +++ b/src/librustc_incremental/persist/load.rs @@ -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 { diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index aa9d1f4c1536..b7bc9ee7566c 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -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};