Skip to content

save-analysis: use absolute paths for file names #30077

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 27, 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
2 changes: 1 addition & 1 deletion src/librustc_trans/save/recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ impl<'a, 'tcx: 'a> FmtStrs<'a, 'tcx> {
pub fn external_crate_str(&mut self, span: Span, name: &str, num: ast::CrateNum) {
let lo_loc = self.span.sess.codemap().lookup_char_pos(span.lo);
self.record_without_span(ExternalCrate,
svec!(name, num, lo_loc.file.name),
svec!(name, num, SpanUtils::make_path_string(&lo_loc.file.name)),
span);
}

Expand Down
13 changes: 12 additions & 1 deletion src/librustc_trans/save/span_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use rustc::session::Session;
use save::generated_code;

use std::cell::Cell;
use std::env;
use std::path::Path;

use syntax::ast;
use syntax::codemap::*;
Expand All @@ -35,6 +37,15 @@ impl<'a> SpanUtils<'a> {
}
}

pub fn make_path_string(file_name: &str) -> String {
let path = Path::new(file_name);
if path.is_absolute() {
path.clone().display().to_string()
} else {
env::current_dir().unwrap().join(&path).display().to_string()
}
}

// Standard string for extents/location.
#[rustfmt_skip]
pub fn extent_str(&self, span: Span) -> String {
Expand All @@ -47,7 +58,7 @@ impl<'a> SpanUtils<'a> {

format!("file_name,\"{}\",file_line,{},file_col,{},extent_start,{},extent_start_bytes,{},\
file_line_end,{},file_col_end,{},extent_end,{},extent_end_bytes,{}",
lo_loc.file.name,
SpanUtils::make_path_string(&lo_loc.file.name),
lo_loc.line, lo_loc.col.to_usize(), lo_pos.to_usize(), lo_pos_byte.to_usize(),
hi_loc.line, hi_loc.col.to_usize(), hi_pos.to_usize(), hi_pos_byte.to_usize())
}
Expand Down