about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2016-08-02 19:11:46 -0400
committerNiko Matsakis <niko@alum.mit.edu>2016-08-02 19:11:46 -0400
commitb13d5041f65df03bd3a34070cb08d339fa629f18 (patch)
treef2eb60aa0eaa392d3231cb16713bb5371d28f3b1
parent94acff180369077c64b19c1302dd48d390011ef5 (diff)
downloadrust-b13d5041f65df03bd3a34070cb08d339fa629f18.tar.gz
rust-b13d5041f65df03bd3a34070cb08d339fa629f18.zip
improve log when something no longer exists
-rw-r--r--src/librustc_incremental/persist/directory.rs23
-rw-r--r--src/librustc_incremental/persist/load.rs14
-rw-r--r--src/librustc_incremental/persist/save.rs1
3 files changed, 29 insertions, 9 deletions
diff --git a/src/librustc_incremental/persist/directory.rs b/src/librustc_incremental/persist/directory.rs
index 85aa9d28e5f..61c14adb3a0 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!("<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| {
diff --git a/src/librustc_incremental/persist/load.rs b/src/librustc_incremental/persist/load.rs
index b47f2221e56..793a0466c31 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 aa9d1f4c153..b7bc9ee7566 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};