about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2015-11-04 10:16:06 +1300
committerNick Cameron <ncameron@mozilla.com>2015-11-04 10:16:06 +1300
commit6252af9ce10f522dbd5b58bdbbeff1b3e8464066 (patch)
tree9822795c7560f579978b08fd2b9c905bb408ab0d
parentde11d2aa835ff6bbb0a8b6fcef1ff0a1174418b3 (diff)
downloadrust-6252af9ce10f522dbd5b58bdbbeff1b3e8464066.tar.gz
rust-6252af9ce10f522dbd5b58bdbbeff1b3e8464066.zip
save-analysis: emit the crate root
-rw-r--r--src/librustc_trans/save/dump_csv.rs11
-rw-r--r--src/librustc_trans/save/recorder.rs6
2 files changed, 13 insertions, 4 deletions
diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs
index f6f504e27ae..3ea631bd7fb 100644
--- a/src/librustc_trans/save/dump_csv.rs
+++ b/src/librustc_trans/save/dump_csv.rs
@@ -107,8 +107,17 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
     }
 
     pub fn dump_crate_info(&mut self, name: &str, krate: &ast::Crate) {
+        let source_file = self.tcx.sess.local_crate_source_file.as_ref();
+        let crate_root = match source_file {
+            Some(source_file) => match source_file.file_name() {
+                Some(_) => source_file.parent().unwrap().display().to_string(),
+                None => source_file.display().to_string(),
+            },
+            None => "<no source>".to_owned(),
+        };
+
         // The current crate.
-        self.fmt.crate_str(krate.span, name);
+        self.fmt.crate_str(krate.span, name, &crate_root);
 
         // Dump info about all the external crates referenced from this crate.
         for c in &self.save_ctxt.get_external_crates() {
diff --git a/src/librustc_trans/save/recorder.rs b/src/librustc_trans/save/recorder.rs
index a32d8b1b761..34eb1d28263 100644
--- a/src/librustc_trans/save/recorder.rs
+++ b/src/librustc_trans/save/recorder.rs
@@ -198,7 +198,7 @@ impl<'a, 'tcx: 'a> FmtStrs<'a, 'tcx> {
                               vec!("name", "crate", "file_name"),
                               false,
                               false),
-            Crate => ("crate", vec!("name"), true, false),
+            Crate => ("crate", vec!("name", "crate_root"), true, false),
             FnCall => ("fn_call",
                        vec!("refid", "refidcrate", "qualname", "scopeid"),
                        true,
@@ -658,8 +658,8 @@ impl<'a, 'tcx: 'a> FmtStrs<'a, 'tcx> {
         self.check_and_record(Typedef, span, sub_span, svec!(id, qualname, value));
     }
 
-    pub fn crate_str(&mut self, span: Span, name: &str) {
-        self.record_with_span(Crate, span, span, svec!(name));
+    pub fn crate_str(&mut self, span: Span, name: &str, crate_root: &str) {
+        self.record_with_span(Crate, span, span, svec!(name, crate_root));
     }
 
     pub fn external_crate_str(&mut self, span: Span, name: &str, num: ast::CrateNum) {