Skip to content

Commit 1ad89e0

Browse files
committed
Auto merge of #29550 - nrc:save-root, r=alexcrichton
2 parents cc403b6 + 6252af9 commit 1ad89e0

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/librustc_trans/save/dump_csv.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,17 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
107107
}
108108

109109
pub fn dump_crate_info(&mut self, name: &str, krate: &ast::Crate) {
110+
let source_file = self.tcx.sess.local_crate_source_file.as_ref();
111+
let crate_root = match source_file {
112+
Some(source_file) => match source_file.file_name() {
113+
Some(_) => source_file.parent().unwrap().display().to_string(),
114+
None => source_file.display().to_string(),
115+
},
116+
None => "<no source>".to_owned(),
117+
};
118+
110119
// The current crate.
111-
self.fmt.crate_str(krate.span, name);
120+
self.fmt.crate_str(krate.span, name, &crate_root);
112121

113122
// Dump info about all the external crates referenced from this crate.
114123
for c in &self.save_ctxt.get_external_crates() {

src/librustc_trans/save/recorder.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl<'a, 'tcx: 'a> FmtStrs<'a, 'tcx> {
198198
vec!("name", "crate", "file_name"),
199199
false,
200200
false),
201-
Crate => ("crate", vec!("name"), true, false),
201+
Crate => ("crate", vec!("name", "crate_root"), true, false),
202202
FnCall => ("fn_call",
203203
vec!("refid", "refidcrate", "qualname", "scopeid"),
204204
true,
@@ -658,8 +658,8 @@ impl<'a, 'tcx: 'a> FmtStrs<'a, 'tcx> {
658658
self.check_and_record(Typedef, span, sub_span, svec!(id, qualname, value));
659659
}
660660

661-
pub fn crate_str(&mut self, span: Span, name: &str) {
662-
self.record_with_span(Crate, span, span, svec!(name));
661+
pub fn crate_str(&mut self, span: Span, name: &str, crate_root: &str) {
662+
self.record_with_span(Crate, span, span, svec!(name, crate_root));
663663
}
664664

665665
pub fn external_crate_str(&mut self, span: Span, name: &str, num: ast::CrateNum) {

0 commit comments

Comments
 (0)