Skip to content

save-analysis: emit the crate root #29550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/librustc_trans/save/dump_csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/save/recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down